ContentsThe library

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 p−1p - 1, which is

zero only when pp 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 contents

This 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

The rest of this course

  1. 01The Number a Model Is Really Asked For
  2. 02Three Reasons the Logarithm Is Not Optionalopening only
  3. 03The Loss, Written Out in Fullopening only
  4. 04Turning Scores Into a Distributionopening only
  5. 05The Simplest Gradient in the Subjectopening only
  6. 06The Floor the Loss Cannot Go Belowopening only
  7. 07What a Perplexity of Twelve Meansopening only
  8. 08When a Low Loss Still Lies to Youyou are here

Read alongside