import numpy def relu(x): return x if x > 0 else 0 relu_v = numpy.vectorize(relu) x = numpy.arange(-10, 11) / 5 print(repr(x)) print(repr(relu_v(x)))
Standard input is empty
array([-2. , -1.8, -1.6, -1.4, -1.2, -1. , -0.8, -0.6, -0.4, -0.2, 0. ,
0.2, 0.4, 0.6, 0.8, 1. , 1.2, 1.4, 1.6, 1.8, 2. ])
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2])