Theory

The number you trusted

At the end of lesson 6 the "training accuracy" was 89.5 %. A nice number. And you trusted it — because you had never seen any other.

This lesson reveals what that number actually measured.

It measured how well the model recognises images it trained on. That is like an exam whose questions the student saw before the exam: a high mark, but it says not "learned" but "memorised". The network you train here has 269 000 numbers — and only 10 000 images to learn from. There is room to memorise.

What changes

Until now you had one dataset. From now on — two, and they never mix:

set purpose does the model see it while learning
train it learns from this yes, every epoch
validation we judge with it no — never

Training accuracy says "how well it memorised". Validation accuracy says "how well it recognises what it has not seen". The second number is the real one.

What this lesson brings

What What it does
train / val split two sets that share not a single image
the gap training accuracy minus validation accuracy — a measure of overfitting
dropout randomly "switches off" some neurons while training
weight decay penalises large numbers
early stopping stops training when validation loss stops improving

The lesson climbs in steps

  1. Watch. A real training run in which the gap opens up epoch by epoch.
  2. Fill the holes. The data split — two lines everything after them depends on.
  3. Write it yourself. Dropout, model.eval(), and a fit with validation and early stopping.
  4. Run it. You will see the honest number — and learn that regularisation does not quite do what you expected.

Honest in advance

Training accuracy keeps climbing, while validation accuracy stops climbing. That is the gap. It can be improved: dropout, weight decay and early stopping narrow it. But they do it first of all by pushing training accuracy down, not by pushing validation accuracy up. The honest number after all that effort is about the same ~86 % you would get without it. The lesson is still worth it: now you know how much your model can actually do.