I trained a model (per the MNIST tutorial) and saved it:
saver = tf.train.Saver()
save_path = saver.save(sess,'/path/to/model.ckpt')
I want to use the saved model in order to find labels for a new batch of images. I load the model and test it with a database:
# load MNIST data
folds = build_database_tuple.load_data(data_home_dir='/path/to/database')
# starting the session. using the InteractiveSession we avoid build the entiee comp. graph before starting the session
sess = tf.InteractiveSession()
# start building the computational graph
...
BUILD AND DEFINE ALL THE LAYERS
...
y_conv=tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)
# TRAIN AND EVALUATION:
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv), reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.initialize_all_variables())
saver = tf.train.Saver()
# Restore variables from disk.
savepath = '/path/to/model.ckpt'
saver.restore(sess, save_path=savepath)
print("Model restored.")
print("test accuracy %g"%accuracy.eval(feed_dict={x: folds.test.images, y_: folds.test.labels, keep_prob: 1.0}))
Although I can load and test the model, how do I get the y' array that contains the predictions for the database images?
I scanned the web and found a lot of answers for this question, but I couldn't fit those answers to this particular case. For example, I found this answer about the CIFAR10 tutorial but it's very different from the MNIST tutorial.