fork download
  1. import numpy
  2.  
  3. def relu(x): return x if x > 0 else 0
  4. relu_v = numpy.vectorize(relu)
  5.  
  6. x = numpy.arange(-10, 11) / 5
  7. print(repr(x))
  8. print(repr(relu_v(x)))
Success #stdin #stdout 0.1s 92224KB
stdin
Standard input is empty
stdout
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])