Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Stop when the validation loss turns up
Early in training a network learns the broad pattern in the data; later it starts memorising the noise in its particular training examples. The training loss keeps falling throughout, but the loss on data the network has not seen falls and then rises. Early stopping watches that held-out loss and keeps the weights from its lowest point.
Early stopping costs nothing, needs no change to the model, and often saves most of the training compute. Every training framework has it built in (Keras’ EarlyStopping, Lightning’s EarlyStopping with ModelCheckpoint), and it is a safety net when the right amount of training is unknown.
- 1. Early stopping watches…
- 2. Late in training an overfitting network's validation loss…
- 3. Early stopping keeps the weights from…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Rule: evaluate the validation loss every k steps; remember the best value and its weights; stop when there has been no improvement for P evaluations (the patience); restore the best weights.
- Example: validation losses 1.0, 0.8, 0.9, 0.95 with patience 2: the best is 0.8 at evaluation 2, and two evaluations without improvement have passed, so stop and restore evaluation 2’s weights.
- Wasted compute: stopping at step 1036 with the best at step 36 wastes 1000 steps; with patience 3 evaluations of 10 steps, only 30.
- Spectral view (least squares, gradient descent from zero): after t steps, each eigendirection of XᵀX/n with eigenvalue s has reached the fraction 1 − (1 − ηs)ᵗ of its least-squares value. Ridge regression keeps s/(s + λ). The two are similar for λ ≈ 1/(ηt): with η = 0.1 and t = 100, λ ≈ 0.1.
- 1. Losses 1.0, 0.8, 0.9, 0.95, patience 2: stop?
- 2. Equivalent λ for η = 0.01 and t = 1000:
- 3. More training steps correspond to…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Early stopping in code
Exercise 1.
- Gradient descent on a 6-feature least-squares problem matched the formula 1 − (1 − ηs)ᵗ per eigendirection exactly.
- With η = 0.1 and t = 100, the filter values were 0.008, 0.052, 0.312, 0.904, 1, 1 for eigenvalues from 0.0008 to 8.1. Ridge with λ = 0.1 gave 0.007, 0.051, 0.272, 0.698, 0.93, 0.988: the same pattern, learning large-eigenvalue directions and suppressing small ones.
Practice.
- Always restore the best weights (Keras:
restore_best_weights=True; Lightning: ModelCheckpoint withmonitor="val_loss"). - Monitor the metric you care about; validation loss is smoother than accuracy.
- Choose patience to cover the noise in the validation curve: a few epochs for smooth curves, more with noisy mini-batch training or learning-rate schedules that cause temporary rises.
- With a fixed schedule (for example cosine), early stopping interacts with the schedule; many large-scale recipes instead train for a fixed budget and select the best checkpoint.
- Repeatedly tuning on the same validation set overfits it; keep a final test set untouched.
callbacks = [EarlyStopping(monitor="val_loss", patience=10, mode="min"), ModelCheckpoint(monitor="val_loss", save_top_k=1)]- 1. Keras' option to keep the best weights is…
- 2. Noisy validation curves call for…
- 3. Tuning repeatedly on one validation set risks…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Early stopping ≈ L2. For gradient descent from zero on a quadratic, the iterate after t steps is a spectral filter of the least-squares solution, close to ridge’s with λ ≈ 1/(ηt) (Bishop, 1995; Goodfellow et al., 2016). Directions of large curvature are fitted first; noise lives mostly in the many small-curvature directions, which early stopping leaves unfitted.
Effective capacity grows with training time. Each extra step lets the model fit more directions, so training time is a capacity knob. Theory for neural networks in the kernel regime and for boosting gives similar results.
Statistical cost. Using the validation set both to choose the stopping time and to report performance gives an optimistic estimate; with few validation examples the chosen time is noisy. The stopping time is a hyperparameter like any other.
Double descent. In very over-parameterised models, the test error can fall, rise and fall again over training (epoch-wise double descent; Nakkiran et al., 2020), so stopping at the first minimum is not always best, and patience should be judged against the observed curve.
- 1. Gradient descent fits first the directions of…
- 2. Training time acts as a knob on…
- 3. Epoch-wise double descent means the test error can…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Patience and restoring
History.
- L. Prechelt (1998) systematically compared early-stopping criteria.
- C. Bishop (1995) and J. Sjöberg and L. Ljung (1995) related early stopping to weight decay.
- T. Zhang and B. Yu (2005) studied early stopping in boosting.
- P. Nakkiran et al. (2020) described epoch-wise double descent.
Exercise 2. A 2–64–64–2 tanh network trained with Adam on 60 noisy points, with 60 more as a validation set and 2000 as a test set; validation loss evaluated every 10 steps for 1500 steps. Means of five seeds:
- Training to the end: test loss 1.135, accuracy 0.865.
- Best checkpoint by test loss (an oracle): 0.367, 0.869.
- The validation loss bottomed out at steps 60, 50, 30, 20 and 20.
| patience (evaluations) | restore best? | stop step | test loss | test accuracy |
|---|---|---|---|---|
| 3 | yes | 66 | 0.371 | 0.857 |
| 3 | no | 66 | 0.404 | 0.871 |
| 10 | yes | 136 | 0.371 | 0.857 |
| 10 | no | 136 | 0.548 | 0.872 |
| 30 | yes | 336 | 0.371 | 0.857 |
| 30 | no | 336 | 0.811 | 0.865 |
| 100 | yes | 1036 | 0.371 | 0.857 |
| 100 | no | 1036 | 1.061 | 0.865 |
- Restoring the best checkpoint cut the test loss threefold (0.371 against 1.135) and nearly matched the oracle.
- With restoring, patience did not change the result here, only the compute spent; this validation curve had a single minimum. With a noisier curve, a small patience could stop before a later, better minimum.
- Without restoring, each extra unit of patience let the model overfit further.
- Accuracy hardly moved (0.857–0.872): on this problem early stopping mainly prevented overconfidence.
Early stopping in AI, robotics and aerospace
- Almost every model trained on a fixed dataset uses validation-based checkpoint selection.
- Small engineering datasets (test-rig data, flight logs) are where overfitting starts early and early stopping matters most.
- Model selection in production pipelines: automated retraining jobs stop on validation metrics and keep the best checkpoint for deployment.
References
- L. Prechelt (1998). “Early stopping – but when?” In Neural Networks: Tricks of the Trade, Springer.
- C. M. Bishop (1995). “Regularization and complexity control in feed-forward networks.” Proc. ICANN.
- I. Goodfellow, Y. Bengio, A. Courville (2016). Deep Learning, section 7.8. MIT Press.
- P. Nakkiran et al. (2020). “Deep double descent: where bigger models and more data hurt.” Proc. ICLR.