Supposing I have a vector in Theano and some of the elements are inf
, how do I remove them? Consider the following example:
import numpy as np
import theano
from theano import tensor
vec = tensor.dvector('x')
fin = vec[(~tensor.isinf(vec)).nonzero()]
f = theano.function([vec], fin)
According to the Theano documentation, this should remove the elements via indexing. However, this is not the case as f([1,2,np.inf])
returns array([ 1., 2., inf])
.
How can I do this so that f([1,2,np.inf])
returns array([ 1., 2.])
?
I found an awkward workaround
For your example: