Apply the Rectified Linear Unit elementwise:
ReLU(x)=max(0,x)Here, x is each input value. Return the transformed values as a NumPy array with the same shape as the input.
Input: x = [-2, -1, 0, 3]
Output: [0.0, 0.0, 0.0, 3.0]
Explanation: Negative values become zero while nonnegative values remain unchanged.
Input: x = 5
Output: 5.0
Input: x = [[-1, 2], [3, -4]]
Output: [[0.0, 2.0], [3.0, 0.0]]
Convert the input with np.asarray(x, dtype=float).
Use np.maximum(0.0, x) for the elementwise threshold.
Sign in to take notes on this problem
Accepts: any
Apply the Rectified Linear Unit elementwise:
ReLU(x)=max(0,x)Here, x is each input value. Return the transformed values as a NumPy array with the same shape as the input.
Input: x = [-2, -1, 0, 3]
Output: [0.0, 0.0, 0.0, 3.0]
Explanation: Negative values become zero while nonnegative values remain unchanged.
Input: x = 5
Output: 5.0
Input: x = [[-1, 2], [3, -4]]
Output: [[0.0, 2.0], [3.0, 0.0]]
Convert the input with np.asarray(x, dtype=float).
Use np.maximum(0.0, x) for the elementwise threshold.
Sign in to take notes on this problem
Accepts: any