Skip to content

Instantly share code, notes, and snippets.

@JoshVarty
Last active March 13, 2018 03:04
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/9c444abd5f62b099b8e04595c8940eca to your computer and use it in GitHub Desktop.
Save JoshVarty/9c444abd5f62b099b8e04595c8940eca to your computer and use it in GitHub Desktop.
saver = tf.train.Saver() #Create saver
num_steps = 1000
batch_size = 100
for step in range(num_steps):
offset = (step * batch_size) % (train_labels.shape[0] - batch_size)
batch_images = train_images[offset:(offset + batch_size), :]
batch_labels = train_labels[offset:(offset + batch_size), :]
feed_dict = {input: batch_images, labels: batch_labels}
_, c, acc = session.run([optimizer, cost, accuracy], feed_dict=feed_dict)
if step % 100 == 0:
print("Cost: ", c)
print("Accuracy: ", acc * 100.0, "%")
saver.save(session, "/tmp/vggnet/vgg_net.ckpt", global_step=step) #Save session every 100 mini-batches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment