Created
January 10, 2018 19:21
-
-
Save ricklentz/ab63aaf9e485516d39f2b3b87c497674 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
import numpy as np | |
# Write a function that takes as input two lists Y, P, | |
# and returns the float corresponding to their cross-entropy. | |
def cross_entropy(Y, P): | |
cross_entropy = 0 | |
for i in range(len(Y)): | |
cross_entropy -= Y[i]*np.log(P[i]) + (1-Y[i])*np.log(1-P[i]) | |
return cross_entropy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment