All problems
ReLU
Problem
Apply the ReLU activation function element-wise.
If the input is a list, return a list where each element is max(0, x_i). If the input is a number, return max(0, x).
Test cases
case 1
in: [[-1,0,1,2]]
expected: [0,0,1,2]
case 2
in: [-5]
expected: 0
case 3
in: [5]
expected: 5
case 4
in: [[3,-3,0]]
expected: [3,0,0]
Starter codePython
def relu(x):
# Your code here
pass4 test cases · run your code against them in the editor