5

The Variable initializer provides a validate_shape parameter so that you can change a Variable shape after initialization.

However, it doesn't look like get_variable() has that parameter and instead uses the default value of validate_shape=False when creating a new Variable. How can you create a shared Variable whose shape you can change after initialization?

Petrarch
  • 167
  • 1
  • 8
  • 1
    Currently this isn't supported in the Variable Scope API (for shared variables). Can you share more about your use case, in case there is an alternative workaround that we can suggest? – mrry Dec 04 '15 at 18:50
  • @mrry I was implementing the methods from the Net2Net paper arxiv.org/pdf/1511.05641v2.pdf (which the authors say they did in tensorflow) and had to be able to change the shape of some of the weight and bias tensors after training a model for some time. Ultimately I used tf.assign using the method you mentioned in http://stackoverflow.com/a/33662680/1187026 . It seemed to work but I haven't tested my implementation thoroughly enough to be sure and am only using it in a single GPU environment. – Petrarch Dec 07 '15 at 17:11

1 Answers1

1

It seems based on the docs here that the validate_shape parameter is now supported as desired, in case anyone else stumbles upon this question.