title: Resume trained variables from last training
body: <p>I am trying to resume from last training but I am able to save the model but not restore it. I have the following code, and its running without errors. I know it is not restoring it because the loss value goes back to big values when I restart training.</p>
  
  <p>Any help?</p>
  
  <pre><code>ckpt_path = os.path.abspath(os.path.dirname(__file__)) + '/weights/'
  
  labels_net, loss = vgg16(crop_size)
  optimizer = tf.train.AdamOptimizer(learning_rate=0.0001).minimize(loss)
  saver = tf.train.Saver(max_to_keep=3)
  
  # Train
  with tf.Session() as sess:
  
      # Load previous weights
      if os.listdir(ckpt_path) ==[]:
          sess.run(tf.global_variables_initializer())
      else:
          for file in os.listdir(ckpt_path):
              if 'vgg16' in file:
                  try:
                      saver = tf.train.import_meta_graph(os.path.join(ckpt_path+file))
                      saver.restore(sess, ckpt_path+'vgg16-2')
                      print('Resuming training....')
                  except:
                      sess.run(tf.global_variables_initializer())
              else:
                  sess.run(tf.global_variables_initializer())
  
      print('Epoch', 'Training loss')
      for epoch_i in range(epochs):
          for batch_i in range(batches):
  
              batch_crops = getBatch(crops_train, batch_i, batch_size)
              batch_labels = getBatch(labels_train, batch_i, batch_size)
              x = sess.graph.get_tensor_by_name('x:0')
              y = sess.graph.get_tensor_by_name('y:0')
              sess.run(optimizer, feed_dict={x: batch_crops, y: batch_labels})#, options=run_options, run_metadata=run_metadata)
  
          train_loss = sess.run(loss, feed_dict={x: batch_crops, y: batch_labels})   
          print(epoch_i+1, train_loss)
          saver.save(sess, ckpt_path+'vgg16', global_step=2)
  </code></pre>