title: Restore subset of variables in Tensorflow
body: <p>I am training a Generative Adversarial Network (GAN) in tensorflow, where basically we have two different networks each one with its own optimizer.</p>
  
  <pre><code>self.G, self.layer = self.generator(self.inputCT,batch_size_tf)
  self.D, self.D_logits = self.discriminator(self.GT_1hot)
  
  ...
  
  self.g_optim = tf.train.MomentumOptimizer(self.learning_rate_tensor, 0.9).minimize(self.g_loss, global_step=self.global_step)
  
  self.d_optim = tf.train.AdamOptimizer(self.learning_rate, beta1=0.5) \
                        .minimize(self.d_loss, var_list=self.d_vars)
  </code></pre>
  
  <p>The problem is that I train one of the networks (g) first, and then, I want to train g and d together. However, when I call the load function:</p>
  
  <pre><code>self.sess.run(tf.initialize_all_variables())
  self.sess.graph.finalize()
  
  self.load(self.checkpoint_dir)
  
  def load(self, checkpoint_dir):
      print(" [*] Reading checkpoints...")
  
      ckpt = tf.train.get_checkpoint_state(checkpoint_dir)
      if ckpt and ckpt.model_checkpoint_path:
          ckpt_name = os.path.basename(ckpt.model_checkpoint_path)
          self.saver.restore(self.sess, ckpt.model_checkpoint_path)
          return True
      else:
          return False
  </code></pre>
  
  <p>I have an error like this (with a lot more traceback):</p>
  
  <pre><code>Tensor name "beta2_power" not found in checkpoint files checkpoint/MR2CT.model-96000
  </code></pre>
  
  <p>I can restore the g network and keep training with that function, but when I want to star d from scratch, and g from the the stored model I have that error.</p>