Created
September 4, 2017 03:08
-
-
Save vrjkmr/6a8e5b9f4c79fd0285e027c7c8048c3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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