Skip to content

Instantly share code, notes, and snippets.

@JoshVarty
Created March 13, 2018 18: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/1973083863288439238db13d3e7c2058 to your computer and use it in GitHub Desktop.
Save JoshVarty/1973083863288439238db13d3e7c2058 to your computer and use it in GitHub Desktop.
input = tf.placeholder(tf.float32, shape=(None, 28, 28, 1), name="input")
labels = tf.placeholder(tf.float32, shape=(None, 10), name="labels")
...
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=labels), name="cost")
...
predictions = tf.nn.softmax(logits, name="predictions")
correct_prediction = tf.equal(tf.argmax(labels, 1), tf.argmax(predictions, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32), name="accuracy")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment