Created
December 25, 2018 05:31
-
-
Save jainakshansh/204d2b6a10041cf491edaaa0d36de3ba to your computer and use it in GitHub Desktop.
The Cross-Entropy Algorithm - Facebook Udacity PyTorch Challenge
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
import numpy as np | |
def cross_entropy(Y, P): | |
Y = np.float_(Y) | |
P = np.float_(P) | |
return -np.sum(Y * np.log(P) + (1 - Y) * np.log(1 - P)) | |
Y = [1, 0, 1, 1] | |
P = [0.4, 0.6, 0.1, 0.5] | |
print(cross_entropy(Y, P)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment