title: How to initialize tensorflow variable that wasn't saved other than with tf.global_variables_initializer()
body: <p>I was looking at how to save/load specific variables in tensorflow.</p>
  
  <p>I can load and save specific variables with no problem, however, I can't figure out how to initialize the remaining unsaved variables without using</p>
  
  <pre><code>sess.run(tf.global_variables_initializer())   
  </code></pre>
  
  <p>then overwriting the saved variable with:</p>
  
  <pre><code>new_saver.restore(sess,'my_test_model2')
  </code></pre>
  
  <p>This works and initializes the unsaved Variable (w2) and restores the saved variable (w1) but seems very kludgy and unphythonic.</p>
  
  <p>I want to know how to get rid of the </p>
  
  <pre><code>tf.global_variables_initializer()
  </code></pre>
  
  <p>,at the end where I restore the w1 variable, to something work pythonic.</p>
  
  <p>I tried <code>sess.run(tf.variables_initializer([w2]))</code> and got input: "^w2/Assign" is not an element of this graph.)</p>
  
  <p>I also tried <code>sess.run(tf.variables_initializer(["w2:0"]))</code> 
   and got AttributeError: 'str' object has no attribute 'initializer'
      import tensorflow as tf</p>
  
  <pre><code>print(tf.__version__)
  w1 = tf.Variable(tf.linspace(0.0, 0.5, 6), name="w1")
  w2 = tf.Variable(tf.linspace(1.0, 5.0, 6), name="w2")
  saver = tf.train.Saver({'w1':w1})
  sess = tf.Session()
  sess.run(tf.global_variables_initializer())
  for v in tf.global_variables():
        print (v.name)
  
  print(sess.run(["w1:0"]))
  print(sess.run(["w2:0"]))
  
  saver.save(sess, 'my_test_model')
  
  tf.reset_default_graph()
  
  print ('-'*80 )
  
  w1 = tf.Variable(tf.linspace(10.0, 50.0, 6), name="w1")
  w2 = tf.Variable(tf.linspace(100.0, 500.0, 6), name="w2")
  saver = tf.train.Saver({'w1':w1})
  sess = tf.Session()
  sess.run(tf.global_variables_initializer())
  for v in tf.global_variables():
        print (v.name)
  
  print(sess.run(["w1:0"]))
  print(sess.run(["w2:0"]))
  
  saver.save(sess, 'my_test_model2')  
  
  tf.reset_default_graph()
  
  print ('-'*80 )
  print("Let's load w1 \n")  
  
  with tf.Session() as sess:
    # Loading the model structure from 'my_test_model.meta'
    new_saver = tf.train.import_meta_graph('my_test_model.meta')
    # I do this to make sure w1:0 and w2:0 are variables
    for v in tf.global_variables():
          print (v.name)  
    sess.run(tf.global_variables_initializer())  #&lt;----- line I want to make more pythonic
  #   sess.run(tf.variables_initializer([w2]))  # input: "^w2/Assign" is not an element of this graph.)
  #   sess.run(tf.variables_initializer(["w2:0"])) #AttributeError: 'str' object has no attribute 'initializer'
  
  # Loading the saved "w1" Variable
    new_saver.restore(sess,'my_test_model2')
  
    print(sess.run(["w1:0"]))
    print(sess.run(["w2:0"]))    
  </code></pre>