title: Reuse value of TensorFlow Variable between sessions without writing to disk
body: <p>In sklearn, I'm used to having a model that I can run <code>fit</code> and then <code>predict</code> on. However, with TensorFlow, I'm having trouble loading the learned parameters from <code>fit</code> when I'm calling <code>predict</code>. It boils down to me not knowing how to reuse the value of a variable between sessions. For example,</p>
  
  <pre><code>import tensorflow as tf
  
  x = tf.Variable(0.0)
  
  # fit code
  with tf.Session() as sess1:
      sess1.run(tf.global_variables_initializer())
      sess1.run(tf.assign(x, 1.0)) # at end of training, x = 1.0
  
  # predict code
  with tf.Session() as sess2:
      sess2.run(tf.global_variables_initializer())
      print(sess2.run(x)) # want this to be 1.0, but is 0.0
  </code></pre>
  
  <p>I can think of one workaround, but it seems really hacky, and would be annoying if there are several variables I want to reuse:</p>
  
  <pre><code>import tensorflow as tf
  
  x = tf.Variable(0.0)
  
  # fit code
  with tf.Session() as sess1:
      sess1.run(tf.global_variables_initializer())
      sess1.run(tf.assign(x, 1.0)) # at end of training, x = 1.0
      learned_x = sess1.run(x) # remember value of learned x at end of session
  
  # predict code
  with tf.Session() as sess2:
      sess2.run(tf.global_variables_initializer())
      sess2.run(tf.assign(x, learned_x))
      print(sess2.run(x)) # prints 1.0
  </code></pre>
  
  <p>How do I reuse variables between sessions without writing to disk (i.e. using <code>tf.train.Saver</code>)? Is the workaround I wrote above the right way to do this?</p>