title: ValueError: No variables to optimize
body: <p>I'm trying to calculate <code>l2_loss</code> between two images and get <code>gradient</code> for them. A snippet of my code is given here:</p>
  
  <pre><code>with tf.name_scope("train"):
  
      X = tf.placeholder(tf.float32, [1, None, None, None], name='X')
      y = tf.placeholder(tf.float32, [1, None, None, None], name='y')
      Z = tf.nn.l2_loss(X - y, name="loss")
      step_loss = tf.reduce_mean(Z)
      optimizer = tf.train.AdamOptimizer()
      training_op = optimizer.minimize(step_loss)
  
  init = tf.global_variables_initializer()
  
  with tf.Session() as sess:
      init.run()
      content = tf.gfile.FastGFile('cat.0.jpg', 'rb').read()
      noise = tf.gfile.FastGFile('color_img.jpg', 'rb').read()
      loss_append = []
      for epoch in range(10):
          for layer in layers:
              c = sess.run(layer, feed_dict={input_img: content})
              n = sess.run(layer, feed_dict={input_img: noise})
              sess.run(training_op, feed_dict={X: c, y: n})
  </code></pre>
  
  <p>But it gives the following error:</p>
  
  <pre><code>    Traceback (most recent call last):
     File "/home/noise_image.py",     line 68, in &lt;module&gt;
      training_op = optimizer.minimize(lossss)
     File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training /optimizer.py", line 315, in minimize
      grad_loss=grad_loss)
     File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training   /optimizer.py", line 380, in compute_gradients
      raise ValueError("No variables to optimize.")
  ValueError: No variables to optimize. 
  </code></pre>
  
  <p>How to get rid of it?</p>