Implements the relu function Parameters: vector (np.array,list,tuple): A numpy array of shape (1,n) consisting of real values or a similar list,tuple Returns: relu_vec (np.array): The input numpy array, after applying relu. >>> vec = np.array([-1
(vector: list[float])
| 16 | |
| 17 | |
| 18 | def relu(vector: list[float]): |
| 19 | """ |
| 20 | Implements the relu function |
| 21 | |
| 22 | Parameters: |
| 23 | vector (np.array,list,tuple): A numpy array of shape (1,n) |
| 24 | consisting of real values or a similar list,tuple |
| 25 | |
| 26 | |
| 27 | Returns: |
| 28 | relu_vec (np.array): The input numpy array, after applying |
| 29 | relu. |
| 30 | |
| 31 | >>> vec = np.array([-1, 0, 5]) |
| 32 | >>> relu(vec) |
| 33 | array([0, 0, 5]) |
| 34 | """ |
| 35 | |
| 36 | # compare two arrays and then return element-wise maxima. |
| 37 | return np.maximum(0, vector) |
| 38 | |
| 39 | |
| 40 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected