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.

Not startedJump to quiz

The method

  1. After every epoch, compute the validation cost.
  2. Whenever it's the best so far, save a copy of the weights.
  3. Stop when it hasn't improved for a set number of epochs, the patience.
  4. Restore the saved best weights.
00.510204060epochcostbest: keep these weightspatience used up: stop
trainingvalidation
With a patience of 15 epochs, training stops at epoch 46 and the weights from epoch 31 are restored.

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

Track validation cost each epoch, save the best weights, stop after "patience" epochs without improvement, restore the best. ≈ L2 for linear models.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptIn early stopping, which weights do you keep at the end?
Q2calculateThe validation cost is lowest at epoch 31. With a patience of 15, when does training stop?
Q3conceptWhy does early stopping count as regularisation?
Q4applyThe validation cost ticks up for one epoch, then improves again. Why is a patience period useful here?
Q5interpretBesides preventing overfitting, what else does early stopping decide for you?