title: Changing the shape of a new assigned variable in Tensorflow
body: <p>if you change a tf.Variable using <a href="https://www.tensorflow.org/api_docs/python/tf/assign" rel="nofollow noreferrer">tf.assign</a> with <code>validate_shape=False</code> <a href="https://github.com/tensorflow/tensorflow/issues/10091" rel="nofollow noreferrer">the shape is not updated</a>.</p>
  
  <p>But if I use <a href="https://www.tensorflow.org/api_docs/python/tf/Variable#set_shape" rel="nofollow noreferrer">set_shape</a> to set the new (correct) shape I get a ValueError.</p>
  
  <p>Here a quick example:</p>
  
  <pre><code>import tensorflow as tf 
  
  a = tf.Variable([3,3,3])
  
  with tf.Session() as sess:
      sess.run(tf.global_variables_initializer())
      # [3 3 3]
      print(sess.run(a))
  
      sess.run(tf.assign(a, [4,4,4,4], validate_shape=False))
      # [4 4 4 4]
      print(sess.run(a))
  
  # (3,)
  print(a.get_shape())
  
  # ValueError: Dimension 0 in both shapes must be equal, but are 3 and 4. Shapes are [3] and [4].
  a.set_shape([4])
  </code></pre>
  
  <p>How do I change the shape of the Variable?</p>
  
  <p>Note: I am aware that the code works if I use <code>a = tf.Variable([3,3,3], validate_shape=False)</code> but in my context I will not be able to initialize the variable myself.</p>