I found a solution :

The and operator should be implemented with * and the or operator with +, 
as the python operators do no work properly with theano (as opposed to what 
they say in the docs).

For further readers, the corrected code is :

import theano
import theano.tensor as T
import numpy as np
import matplotlib.pyplot as plt

r = T.scalar()
gate = T.switch( T.ge(r,2.) * T.le(r,3.) , 1., 0.)
f = theano.function([r],gate)
x = np.arange(0.,4.,0.05,dtype='float32')
y = [f(i) for i in x]
plt.plot(x,y)

Which indeed gives the correct output.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to