title: tensorflow - saving and restoring operations
body: <p>I have simple goal of training model in tensorflow saving and restoring it later either in order to continue training or to use some functions/operations. </p>
  
  <p>Here is simple example of the model</p>
  
  <pre><code>import tensorflow as tf
  import numpy as np
  
  BATCH_SIZE = 3
  VECTOR_SIZE = 1
  LEARNING_RATE = 0.1
  
  x = tf.placeholder(tf.float32, [BATCH_SIZE, VECTOR_SIZE],
                     name='input_placeholder')
  y = tf.placeholder(tf.float32, [BATCH_SIZE, VECTOR_SIZE],
                     name='labels_placeholder')
  
  W = tf.get_variable('W', [VECTOR_SIZE, BATCH_SIZE])
  b = tf.get_variable('b', [VECTOR_SIZE], initializer=tf.constant_initializer(0.0))
  
  y_hat = tf.matmul(W, x) + b
  predict = tf.matmul(W, x) + b
  total_loss = tf.reduce_mean(y-y_hat)
  train_step = tf.train.AdagradOptimizer(LEARNING_RATE).minimize(total_loss)
  X = np.ones([BATCH_SIZE, VECTOR_SIZE])
  Y = np.ones([BATCH_SIZE, VECTOR_SIZE])
  all_saver = tf.train.Saver() 
  
  sess= tf.Session()
  sess.run(tf.global_variables_initializer())
  sess.run([train_step], feed_dict = {x: X, y:Y}))
  save_path =  r'C:\some_path\save\\'
  all_saver.save(sess,save_path)
  </code></pre>
  
  <p>Now we restore it here:</p>
  
  <pre><code>meta_path = r'C:\some_path\save\.meta'
  new_all_saver = tf.train.import_meta_graph(meta_path)
  
  graph = tf.get_default_graph()
  all_ops = graph.get_operations()
  for el in all_ops:
      print(el)
  </code></pre>
  
  <p>In restored operation one could not even find <code>predict</code> or <code>train_step</code> from original code. Do I need to name this operations before saving? How can I get <code>predict</code> back and run something like this</p>
  
  <pre><code>sess=tf.Session()
  sess.run([predict], feed_dict = {x:X})
  </code></pre>
  
  <p>P.S. I read many tutorials on saving and restoring in tensorflow, but still have poor understanding how it all works.</p>