This example's true answer is "yes." How much should it cost your model to have said "almost certainly not"?
Drag the point — it's your model's predicted probability that this true-positive example is positive. Near 1 the loss barely moves. Down near 0, it shoots upward without any sign of leveling off.
That's cross-entropy loss. For one example with true label and predicted probability —
- — the cross-entropy loss for one example.
- — the true label, exactly or .
- — the model's predicted probability that the example is positive.
- Only one term is ever active
Since is exactly 0 or 1, exactly one of the two terms in the brackets is ever nonzero — the loss only ever looks at the probability assigned to the true label.
- Confidently wrong predictions blow up
A probability approaching 0 for the correct answer sends toward — and the leading minus sign turns that into a loss with no ceiling at all.
Watch the comparison: squared error tops out at no matter how wrong the prediction gets, but cross-entropy keeps climbing. A model that's confidently wrong gets punished far harder than one that's just wrong.
True label , predicted — confidently wrong:
- Compute the cross-entropy loss
- Compare it to squared error
Squared error for the same case is only — cross-entropy is already nearly three times larger, and would keep growing the more confident the wrong prediction became.
This example’s true label is 1. Drag p until the loss reads (approximately) 0.05.
Cross-entropy is built for probability outputs specifically: it's small when a prediction is confidently correct, and unboundedly large when a prediction is confidently wrong. That's exactly the signal gradient descent needs to fix a badly wrong classifier fast.