The Mathematics of Cross Entropy
When a Low Loss Still Lies to You
Last timeReading the Number
This loss is minimised by telling the truth, and yet trained networks are systematically overconfident. The reason is in the gradient, and there are two standard repairs.
A model can have an excellent loss and probabilities you should not act on. That
sounds like a contradiction, since the previous lessons established that this
loss is minimised only when the model matches the data. The resolution is worth
understanding, because it is the difference between a number you can put in front
of a doctor and a number you cannot.
The objective is not at fault
Among all possible predictors, the one that minimises expected cross entropy is
the true conditional distribution. Not something that merely ranks the classes
correctly: the actual probabilities. A scoring rule with that property is called
strictly proper, and the logarithmic score is the canonical example. So the
objective really does ask for honest numbers, and a well-specified model fitted
on unlimited data would produce them.
What goes wrong is everything between that statement and a real training run.
Where the overconfidence comes from
Recall the gradient from lesson five: the predicted probability minus the target.
With a target of one on the observed class, that gradient is , which is
zero only when is exactly one. The softmax never reaches one. So the pull
towards greater confidence never switches off.
Now consider a network large enough to classify every training example
correctly. It has run out of ranking mistakes to fix, and the only remaining way
to reduce the training loss is to make the probabilities more extreme. Training
continues, the loss keeps falling, and nothing about the model's actual knowledge
improves. What improves is its certainty.
The lesson stops here
5 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents