Skip to content

Instantly share code, notes, and snippets.

@hadifar
Created December 6, 2018 08:43
Show Gist options
  • Save hadifar/1cec97434cd9b54657e3c82e203ed324 to your computer and use it in GitHub Desktop.
Save hadifar/1cec97434cd9b54657e3c82e203ed324 to your computer and use it in GitHub Desktop.
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(train_init_op)
while True:
try:
_, step, c, acc = sess.run([train_step, global_step, cost, accuracy])
if step % 50 == 0:
print("Iter " + str(step) +
", batch loss {:.6f}".format(c) +
", batch Accuracy= {:.5f}".format(acc))
except tf.errors.OutOfRangeError:
print('training is finished...')
break
step = 0
acc = 0
sess.run(test_init_op)
while True:
try:
step = step + 1
acc = acc + sess.run(accuracy)
except tf.errors.OutOfRangeError:
break
print('final accuracy', acc / step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment