Skip to content

Instantly share code, notes, and snippets.

@Alescontrela
Last active June 15, 2018 23:12
Show Gist options
  • Save Alescontrela/2bd8f8696f2617e33b2f0a32d888a456 to your computer and use it in GitHub Desktop.
Save Alescontrela/2bd8f8696f2617e33b2f0a32d888a456 to your computer and use it in GitHub Desktop.
def categoricalCrossEntropy(probs, label):
'''
calculate the categorical cross-entropy loss of the predictions
'''
return -np.sum(label * np.log(probs)) # Multiply the desired output label by the log of the prediction, then sum all values in the vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment