Skip to content

Instantly share code, notes, and snippets.

@risenW
Created July 16, 2018 18:59
Show Gist options
  • Save risenW/931de501ae04ec6d370f57823ac70df1 to your computer and use it in GitHub Desktop.
Save risenW/931de501ae04ec6d370f57823ac70df1 to your computer and use it in GitHub Desktop.
code for Softmax cross entropy loss
y_pred_dist = tf.constant([[1., -3., 10.]])
target_dist = tf.constant([[0.1, 0.02, 0.88]])
softmax_xentropy = tf.nn.softmax_cross_entropy_with_logits(labels=target_dist, logits=y_pred_dist)
print(sess.run(softmax_xentropy))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment