This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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