Log inStart free
LESSON 4.16 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Early stopping

Watch the validation loss turn up, and see training keep its best epoch.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.16 · STOPPING BAYTRAINING LOSS 0.427 → 0.032 IN 200 EPOCHS
01
Stage 1 of 6 · Train
Each epoch, mini-batch SGD updates 17 weights. The training loss falls from 0.427 to 0.032.
Explain it simply

The teal dots are 10 training points: a hidden wave plus noise. The blue curve is the model's fit. Each epoch, the model sees every training point once and nudges its weights. The light red line on the right is the training loss, the average squared miss. It keeps going down, with small bumps, for all 200 epochs.

10 training points. Over 200 epochs of SGD, the training loss falls from 0.427 to 0.032. The fit at epoch 200 bends toward every point.

training points (filled), validation points (hollow)the fit, checkpoints, the kept modelloss: training (light), validation (dark)weights, patiencehidden curve sin 2πx, epochs never run
10 training points · the fittraining loss per epoch00.51−2−1012xydashed: hidden curve sin 2πxfit at epoch 20005010015020000.20.40.60.8epochlosstraining10 training points · the fittraining loss per epoch00.51−2−1012xydashed: hidden curve sin 2πxfit at epoch 20005010015020000.20.40.60.8epochlosstraining
Toy: y = sin 2πx + noise (σ = 0.4) · 10 or 40 training points · 30 validation points · 17 weights · SGD
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
w←w−η ∇Ltrain(w),Ltrain=1n∑i(y^i−yi)2\sy{w}{param}{w} \leftarrow w - \sy{eta}{param}{\eta}\,\nabla \sy{Ltr}{grad}{L_{\text{train}}}(w),\quad L_{\text{train}} = \tfrac{1}{n}\textstyle\sum_i (\sy{yhat}{out}{\hat y_i} - \sy{y}{data}{y_i})^2
η=0.03, batch 3:Ltrain(0)=0.427  →  Ltrain(200)=0.032\eta = 0.03,\ \text{batch } 3:\quad L_{\text{train}}(0) = 0.427 \;\to\; L_{\text{train}}(200) = 0.032

Each step moves the weights downhill on the training loss.

Common mix-ups

MYTHTrain until the training loss stops falling.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With patience 2, does training reach the best epoch, 31?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.