You should create tf.train.Saver after the variables that you want to restore (or save). It must be created in the same graph as those variables.
Let's say Process.forward_propagation(…) also creates the variables in your model, adding the saver creation after this line should work:
forward_propgation_results = Process.forward_propagation(images)
You must pass the new tf.Graph that you created to the tf.Session constructor so you'll need to move the creation of sess inside that with block as well.
The resulting function will be something like:
def evaluate():
with tf.Graph().as_default() as g:
images, labels = Process.eval_inputs(eval_data = eval_data)
forward_propgation_results = Process.forward_propagation(images)
init_op = tf.initialize_all_variables()
saver = tf.train.Saver()
top_k_op = tf.nn.in_top_k(forward_propgation_results, labels, 1)
with tf.Session(graph=g) as sess:
sess.run(init_op)
saver.restore(sess, eval_dir)
print(sess.run(top_k_op))
Hope this answer helps you!
To know more about this, go through the Artificial Intelligence Course.
Learn TensorFlow with the help of this comprehensive video tutorial: