I have the following code:
import theano.tensor as T
Words = theano.shared(value = U, name = 'Words')
zero_vec_tensor = T.vector()
zero_vec = np.zeros(img_w, dtype = theano.config.floatX)
set_zero = theano.function([zero_vec_tensor], updates=[(Words, T.set_subtensor(Words[0,:], zero_vec_tensor))])
Which is compiling fine (where U
is a numpy array of dtype float64
).
To prevent future type error I want to cast my shared tensor Words
into float32
(or theano.config.floatX
which is equivalent as I have set floatX
to float32
in the config file).
I so add Words = T.cast(Words, dtype = theano.config.floatX)
and then I get the following error:
TypeError: ('update target must be a SharedVariable', Elemwise{Cast{float32}}.0)
.
I do not understand why. According to this question, using set_subtensor
should allow me to update a subset of the shared variable.
How can I cast my shared tensor while being able to update it?