title: Can not update a subset of shared tensor variable after a cast
body: <p>I have the following code:</p>
  
  <pre><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))])
  </code></pre>
  
  <p>Which is compiling fine (where <code>U</code> is a numpy array of dtype <code>float64</code>).</p>
  
  <p>To prevent future type error I want to cast my shared tensor <code>Words</code> into <code>float32</code> (or <code>theano.config.floatX</code> which is equivalent as I have set <code>floatX</code> to <code>float32</code> in the config file).</p>
  
  <p>I so add <code>Words = T.cast(Words, dtype = theano.config.floatX)</code> and then I get the following error: </p>
  
  <p><code>TypeError: ('update target must be a SharedVariable', Elemwise{Cast{float32}}.0)</code>. </p>
  
  <p>I do not understand why. According to this <a href="https://stackoverflow.com/questions/15917849/how-can-i-assign-update-subset-of-tensor-shared-variable-in-theano">question</a>, using <code>set_subtensor</code> should allow me to update a subset of the shared variable.</p>
  
  <p>How can I cast my shared tensor while being able to update it?</p>