ReLU Activation
Easy
~10 min
code completion
ReLU: Rectified Linear Unit
ReLU is the most popular activation function in deep learning:
It zeroes out negative values and passes positive values unchanged. Key advantages:
In NumPy: np.maximum(0, z)
Note: np.maximum(0, z) is element-wise; np.max(z) takes the global max — different things!
Your task:
Implement relu(z) that applies ReLU element-wise.
Example Tests
Mixed positive and negative values
Input: {"z":[-3,-1,0,1,3]}
Expected: [0,0,0,1,3]
2D array
Input: {"z":[[1,-1],[2,-2]]}
Expected: [[1,0],[2,0]]
All negative: all zeros
Input: {"z":[-5,-4,-3,-2,-1]}
Expected: [0,0,0,0,0]