Lesson 9.2 · 5 min read · about 40 min to master at a very slow pace
Early Stopping
Watch the validation cost every epoch, keep the best weights, and stop when it stops improving. Why it regularises, and the patience setting.
The method
- After every epoch, compute the validation cost.
- Whenever it's the best so far, save a copy of the weights.
- Stop when it hasn't improved for a set number of epochs, the patience.
- Restore the saved best weights.
Why it regularises
Weights start small and grow as training continues. Stopping early limits how far they can move from their initial values, which limits how wiggly the learned function can become. For a linear model, early stopping is equivalent to L2 regularisation.
It costs one validation pass per epoch, it also chooses the number of epochs for you, and it's used in almost every training run.
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passWhy wait for a patience period instead of stopping at the first increase?
Validation cost is noisy, especially with mini-batches; it often ticks up for an epoch or two and then improves again. Patience avoids stopping on a blip. Because you restore the best weights, waiting a little longer costs only time.
Cheatsheet
Early stopping
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.