Hi,
The only syntax we currently support in tensor.where is the one where
two additional argument are provided, like in:
>>> numpy.where(a > 3, a, a + 3)
array([3, 4, 5, 6, 4, 5, 6, 7, 8, 9])
>>> x = tensor.vector()
>>> tensor.where(x > 3, x, x + 3).eval({x: a})
array([ 3., 4., 5., 6., 4., 5., 6., 7., 8., 9.])
If you want to reproduce the behaviour when only the condition is
provided, you can do that with nonzero:
>>> out, = tensor.nonzero(x > 3)
>>> out.eval({x: a})
array([4, 5, 6, 7, 8, 9])
Note that Theano will return a tuple of 1 array if x.ndim == 1, whereas
numpy returns a single array.
If you are interested in making the "nonzero" feature available from
"tensor.where", please let us know.
On Tue, Nov 22, 2016, [email protected] wrote:
> Dear all,
> I wanna to use np.where in theano. However, it seems that
> theano.tensor.where is not doing the same things as numpy.where will do. Is
> there any function i can use in theano?
> For example,
>
> a = numpy.arange(10)
> index = numpy.where(a>a[0])
>
> How to implement the code above in theano?
>
> --
>
> ---
> 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.
--
Pascal
--
---
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.