Machine Learning & AI
Basic

Categorical Cross-Entropy

Multi-class loss summing the log-probability of the correct class.

Formula

L=iyilogy^iL = -\sum_{i} y_i \log \hat{y}_i

Variables

y_iOne-hot true label
\hat{y}_iPredicted probability

Example

true=class2, p=0.7: L=-log0.7=0.357

Did You Know?

Paired with softmax, this loss has a beautifully simple gradient: predicted minus true.

Share this formula