Created
March 13, 2019 08:24
-
-
Save Tooluloope/e4ab29b16994d72ea4c9d3e1f9d3ef1f to your computer and use it in GitHub Desktop.
This file contains hidden or 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(Al, Y): | |
""" | |
Arguments: | |
AL -- probability vector corresponding to your label predictions, shape (1, number of examples) | |
Y -- true "label" vector (for example: containing 0 if non-cat, 1 if cat), shape (1, number of examples) | |
Returns: | |
cost -- cross-entropy cost | |
""" | |
m = Y.shape[1] | |
cost = -1/m * np.sum(np.multiply(Y, np.log(Al)) + np.multiply((1-Y), np.log(1-Al))) | |
cost = np.squeeze(cost) | |
return cost | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment