What is the equivalent of [a <0] = 0 in Theano?
2 answers
This work:
import theano a=theano.tensor.matrix() idxs=(a<0).nonzero() new_a=theano.tensor.set_subtensor(a[idxs], 0)
Don't forget that Theano is a symbolic language. Thus, the variable a does not change in the user's graph. This is a new variable new_a that contains the new value and still has the old value.
Theano will optimize this to work locally if possible.
+5
source share