title: How to work with multiple models in Tensorflow
body: <p>I have two models <code>m1</code> and <code>m2</code> trained separately. Now I want to keep <code>m1</code> fixed and fine tune <code>m1</code> based on the output of <code>m2</code>. All the variables of <code>m1</code> is under the variable scope <code>"m1/"</code> and the ones of <code>m2</code> is under <code>"m2/"</code>. Here is basically what I did:</p>
  
     <pre class="lang-py prettyprint-override"><code># build m1 and m2
  with tf.device("/cpu:0"):
      m1.build_graph()
      m2.build_graph()
  # indicate the variables of m1 and m2 
  allvars = tf.global_variables()
  m1_vars = [v for v in allvars if v.name.startswith('m1')]
  m2_vars = [v for v in allvars if v.name.startswith('m2')]
  # construct the saver 
  m1_saver = tf.train.Saver(m1_vars)
  m2_saver = tf.train.Saver(m2_vars)
  # Load m2 variables 
  m2_ckpt_state = tf.train.get_checkpoint_state(FLAGS.m2_log_root)
  m2_sess = tf.Session()
  m2_saver.restore(m2_sess, m2_ckpt_state.model_checkpoint_path)
  
  # construct a train supervisor for m1
  m1_sv = tf.train.Supervisor(is_chief=True, saver=m1_saver)
  # construct a session for m1
  m1_sess =  m1_sv.prepare_or_wait_for_session()
  ...
  </code></pre>
  
  <p>But now there is an error in the last line of code :</p>
  
  <pre><code>Traceback (most recent call last):
     File "run_summarization.py", line 407, in &lt;module&gt;
     tf.app.run()
     File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run
  _sys.exit(main(_sys.argv[:1] + flags_passthrough))
     File "run_summarization.py", line 401, in main run_fine_tune(model, ranker, batcher, vocab)
     File "run_summarization.py", line 232, in run_fine_tune sess_context_manager = sv.prepare_or_wait_for_session(config=config)
     File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/supervisor.py", line 719, in prepare_or_wait_for_session
  init_feed_dict=self._init_feed_dict, init_fn=self._init_fn)
     File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/session_manager.py", line 280, in prepare_session
     self._local_init_op, msg))
     RuntimeError: Init operations did not make model ready.  Init op: init, 
     init fn: None, local_init_op: name: "group_deps"
     op: "NoOp"
     input: "^init_1"
     input: "^init_all_tables", error: Variables not initialized: m2/var1, m2/var2, m2/var3...
  </code></pre>
  
  <p>Could you please tell me why this error occurs and how can I fix it? Thanks in advance!</p>