Skip to content

Instantly share code, notes, and snippets.

@hadifar
Created December 6, 2018 08:42
Show Gist options
  • Save hadifar/46161d669c4551c34a9919c0588e1565 to your computer and use it in GitHub Desktop.
Save hadifar/46161d669c4551c34a9919c0588e1565 to your computer and use it in GitHub Desktop.
correct_pred = tf.equal(tf.argmax(pred, 1), y)
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
cost = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y, logits=logit))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
train_step = optimizer.minimize(cost, global_step=global_step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment