Created
July 18, 2018 00:15
-
-
Save llSourcell/0a5b5b1f939223502f981948bec30467 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 cross_entropy(X,y): | |
| """ | |
| X is the output from fully connected layer (num_examples x num_classes) | |
| y is labels (num_examples x 1) | |
| """ | |
| m = y.shape[0] | |
| p = softmax(X) | |
| log_likelihood = -np.log(p[range(m),y]) | |
| loss = np.sum(log_likelihood) / m | |
| return loss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment