I'm having an issue making a basic op that uses theano.tensor.switch.
When I construct a basic function, I get the expected behavior:
>>> x = theano.tensor.fscalar('x')
>>> f = theano.function([x], theano.tensor.switch(0., x, 1.))
>>> f(0.)
array(1.0, dtype=float32)
But, when I try to do this with a gof.Op, it seems to return the switch
operation rather than the value itself:
>>> class TestOp(Op):>>> >>> def make_node(self, x):>>> x =
>>> as_tensor_variable(x)>>> w = theano.tensor.fscalar()>>>
>>> return Apply(self, [x], [w])>>> >>> def perform(self, node, inputs,
>>> outputs):>>> (x,) = inputs>>> (w,) = outputs>>> >>>
>>> w[0] = theano.tensor.switch(0., x, 1.)>>> >>> testop = TestOp()
>>>
>>> f = theano.function([x], testop(x))>>> f(2.)
Elemwise{switch,no_inplace}.0
Any ideas how I could get this latter function to return 1?
Thanks!
-- Peter
--
---
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.