title: Loading two models from Saver in the same Tensorflow session
body: <p>I have two networks: a <code>Model</code> which generates output and an <code>Adversary</code> which grades the output.</p>
  
  <p>Both have been trained separately but now I need to combine their outputs during a single session.</p>
  
  <p>I've attempted to implement the solution proposed in this post: <a href="https://stackoverflow.com/questions/39175945/run-multiple-pre-trained-tensorflow-nets-at-the-same-time">Run multiple pre-trained Tensorflow nets at the same time</a></p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>with tf.name_scope("model"):
      model = Model(args)
  with tf.name_scope("adv"):
      adversary = Adversary(adv_args)
  
  #...
  
  with tf.Session() as sess:
      tf.global_variables_initializer().run()
  
      # Get the variables specific to the `Model`
      # Also strip out the surperfluous ":0" for some reason not saved in the checkpoint
      model_varlist = {v.name.lstrip("model/")[:-2]: v 
                       for v in tf.global_variables() if v.name[:5] == "model"}
      model_saver = tf.train.Saver(var_list=model_varlist)
      model_ckpt = tf.train.get_checkpoint_state(args.save_dir)
      model_saver.restore(sess, model_ckpt.model_checkpoint_path)
  
      # Get the variables specific to the `Adversary`
      adv_varlist = {v.name.lstrip("avd/")[:-2]: v 
                     for v in tf.global_variables() if v.name[:3] == "adv"}
      adv_saver = tf.train.Saver(var_list=adv_varlist)
      adv_ckpt = tf.train.get_checkpoint_state(adv_args.save_dir)
      adv_saver.restore(sess, adv_ckpt.model_checkpoint_path)
  </code></pre>
  
  <p><strong>The problem</strong></p>
  
  <p>The call to the function <code>model_saver.restore()</code> appears to be doing nothing. In another module I use a saver with <code>tf.train.Saver(tf.global_variables())</code> and it restores the checkpoint fine.</p>
  
  <p>The model has <code>model.tvars = tf.trainable_variables()</code>. To check what was happening I used <code>sess.run()</code> to extract the <code>tvars</code> before and after restore. Each time the initial randomly assigned variables are being used and the variables from the checkpoint are not being assigned.</p>
  
  <p>Any thoughts on why <code>model_saver.restore()</code> appears to be doing nothing?</p>