Skip to content

Instantly share code, notes, and snippets.

@JoshVarty
Last active March 14, 2018 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshVarty/3816f4ab97c99332b3b1af69f15d5e59 to your computer and use it in GitHub Desktop.
Save JoshVarty/3816f4ab97c99332b3b1af69f15d5e59 to your computer and use it in GitHub Desktop.
with tf.Session() as session:
#Restore Model
saver = tf.train.Saver() #Create a saver (object to save/restore sessions)
saver.restore(session, "/tmp/vggnet/vgg_net.ckpt") #Restore the session from a previously saved checkpoint
#Now we test our restored model exactly as before
batch_size = 100
num_test_batches = int(len(test_images) / 100)
total_accuracy = 0
total_cost = 0
for step in range(num_test_batches):
offset = (step * batch_size) % (train_labels.shape[0] - batch_size)
batch_images = test_images[offset:(offset + batch_size)]
batch_labels = test_labels[offset:(offset + batch_size)]
feed_dict = {input: batch_images, labels: batch_labels}
c, acc = session.run([cost, accuracy], feed_dict=feed_dict)
total_cost = total_cost + c
total_accuracy = total_accuracy + acc
print("Test Cost: ", total_cost / num_test_batches)
print("Test accuracy: ", total_accuracy * 100.0 / num_test_batches, "%")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment