title: Tensorflow and Variable Scope - How to reuse scopes correctly?
body: <p>I re-designed a GAN which I have previously made with Keras. No Problem so far, however I notice that my model doesn't train correctly depending on the way I implement the scope reuse. Maybe someone could help me understanding what is happening:</p>
  
  <p><strong>Working version:</strong></p>
  
  <pre><code>with tf.variable_scope('g/h0') as scope:
      reuse_scope = scope if reuse else None
  
      h0 = tf.contrib.layers.fully_connected(
          z, 
          4*4*512,
          activation_fn=None,
          reuse=reuse_scope,
          scope='g/h0'
      )
      h0 = tf.nn.relu(h0)
  </code></pre>
  
  <p><strong>Not Working version:</strong></p>
  
  <pre><code>with tf.variable_scope('g/h0') as scope:
      if reuse:
          scope.reuse_variables()
  
      h0 = tf.contrib.layers.fully_connected(
          z, 
          4*4*512,
          activation_fn=None
      )
      h0 = tf.nn.relu(h0)
  </code></pre>
  
  <p><em>Both version lead to a working network, however the second one lead to a network that never updates. And I don't understand why the first version lead to a correct situation.</em></p>
  
  <p>In TensorBoard, the graph appears quite different depending on the version I pick. I suspect the gradient to backpropagate incorrectly. </p>
  
  <p>Is there any way doing this with the second version ? I find it a lot more understandable.</p>