Memorising is not learning
A model can score perfectly on its practice questions and fail the exam. Make one overfit on purpose, and learn the habit that catches it.
Imagine a student who memorises the answers to last year’s exam, word for word. On last year’s paper they score 100%. On this year’s paper, with new questions, they’re lost. They learned the answers, not the subject.
Models do exactly this. It’s called overfitting: the model fits its training examples, including their noise and accidents, so closely that it stops working on anything new. The defence is just as simple as the problem. Hold some examples back. Never train on them, and judge the model only on how it does with those.
That’s what the dots with a white ring have been all along: the test set. “Test accuracy” in these widgets is always measured on them, never on the training dots.
Make it overfit, on purpose
Set this up exactly, then train for about twenty seconds and keep your eye on two numbers:
- Drag Noise up to 0.5. The two classes now overlap, so some dots sit on the “wrong” side purely by chance.
- The network is already big: two hidden layers of 12, with every input ticked (265 knobs).
- Set the learning rate to 1 and press Train.
Watch train loss fall towards zero as the boundary grows tentacles to wrap around individual noisy dots. Now watch test accuracy. When we built this lesson, with these exact settings, it peaked around 83% early on and then fell to about 72% as training went on. The model got better at the dots it had seen and worse at the ones it hadn’t.
Three ways back
- Fewer knobs. Try
4in Hidden layers and onlyxandy. A smaller model can’t memorise the noise, so it’s forced to learn the broad shape. - Stop early. Watch the test accuracy and keep the knobs from its best moment, before memorisation set in.
- More, cleaner data. Noise is what gets memorised. More examples make each accident matter less.
Now earn it. Keep the noise at 0.3 or more and get 85% on the held-back dots. Big networks tend to lose this one; small ones tend to win.
Training loss keeps going down while test accuracy goes down too. What's happening?
That gap - better on seen examples, worse on unseen ones - is the signature of overfitting. The model is fitting accidents of its training set that don't carry over.
Why must the test examples never be used for training?
The only honest measure of 'does this work on new data?' is data the model has never seen. Train on the test set even once and its score stops meaning anything - a check that can no longer fail.
Sources
Missions and quizzes above earn their own XP. This marks the lesson done.