In anano, I have a vector with values around 0 and using switch, I set each value less than 0 to 0:
T.switch(x < 0, 0, x)
How to do the same with numpy?
I think you are looking for something like this:
import numpy as np a= np.array([0,1,-12]) a[a<0]= 0 print a >> [0,1,0]
So, the key is to a[a<0] find all the negative elements.
a[a<0]
Answer the numpy switch analogue question
numpy
numpy.where(x < 0, 0, x)
But especially for this task, I prefer to use a function created for this purpose
x.clip(0)