Skip to content

Instantly share code, notes, and snippets.

@SuvroBaner
Created December 31, 2019 11:39
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 SuvroBaner/b2476a39cc97c8f1195e12be97cd72f0 to your computer and use it in GitHub Desktop.
Save SuvroBaner/b2476a39cc97c8f1195e12be97cd72f0 to your computer and use it in GitHub Desktop.
def compute_cost(Z3, Y):
"""
Arguments:
Z3 -- output of forward propagation (output of the last LINEAR unit), of shape (6, number of examples)
Y -- "true" labels vector placeholder, same shape as Z3
Returns:
cost - Tensor of the cost function
"""
logits = tf.transpose(Z3)
labels = tf.transpose(Y)
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits = logits, labels = labels))
return cost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment