Skip to content

Instantly share code, notes, and snippets.

@vrjkmr
Created September 4, 2017 03:08
Show Gist options
  • Save vrjkmr/6a8e5b9f4c79fd0285e027c7c8048c3c to your computer and use it in GitHub Desktop.
Save vrjkmr/6a8e5b9f4c79fd0285e027c7c8048c3c to your computer and use it in GitHub Desktop.
def compute_cost(Z3, Y):
'''
Computes the cost
Arguments:
Z3 -- output of forward propagation (output of the last LINEAR unit), of shape (10, number_of_examples)
Y -- "true" labels vector placeholder, same shape as Z3
Returns:
cost - Tensor of the cost function
'''
# Get logits (predictions) and labels
logits = tf.transpose(Z3)
labels = tf.transpose(Y)
# Compute cost
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