Quant Memo
Core

Early Stopping and Patience Schedules

Training loss keeps improving as long as the model has capacity to memorize, but validation loss starts getting worse the moment it crosses from learning genuine patterns into overfitting noise; early stopping halts training right at that turning point instead of running to a fixed epoch count.

Prerequisites: Overfitting

Training loss almost always keeps falling, epoch after epoch, as long as the model has enough capacity — eventually it starts memorizing quirks of the specific training examples rather than learning patterns that generalize. Validation loss, measured on data the model never trains on, tells a different story: it falls alongside training loss for a while, then starts rising again once the model has crossed from genuine learning into overfitting. Early stopping watches that validation curve and halts training right around its minimum, instead of running to whatever fixed epoch count was originally planned.

The analogy: knowing when to stop proofreading

Reading a draft over and over keeps finding things to "fix" — but past a certain point, those fixes stop being genuine errors and start being stylistic fiddling that could just as easily make the piece worse for a different reader. A disciplined editor stops at the point where further passes are no longer clearly improving the piece for its actual audience, not at some arbitrary fixed number of read-throughs decided in advance. Early stopping applies the same discipline mechanically: watch a genuinely independent signal (validation performance) and stop right when it stops improving, rather than trusting a fixed schedule set before training even began.

The mechanics: patience

Simply stopping the instant validation loss ticks up even slightly would stop far too early, since validation loss is noisy from batch to batch and can wiggle upward briefly even while the true underlying trend is still improving. Patience (pp) is the number of consecutive epochs without improvement to tolerate before actually stopping:

stop at epoch t if t(tp, t]: Lval(t)<Lvalbest\text{stop at epoch } t \text{ if } \nexists\, t' \in (t-p,\ t]:\ L_{\text{val}}(t') < L_{\text{val}}^{\text{best}}

In words: keep a running record of the best validation loss seen so far, LvalbestL_{\text{val}}^{\text{best}}; if pp epochs pass in a row without a new best, stop training and roll back to the weights from the epoch that actually achieved LvalbestL_{\text{val}}^{\text{best}} — not the weights from the final epoch, which by definition are already pp epochs past the best point.

Worked example 1: tracing a patience-5 schedule by hand

Validation loss by epoch: [0.50,0.42,0.38,0.40,0.37,0.39,0.41,0.44,0.43,0.46][0.50, 0.42, 0.38, 0.40, 0.37, 0.39, 0.41, 0.44, 0.43, 0.46]. Best-so-far updates at epoch 3 (0.380.38) and again at epoch 5 (0.370.37, a new best). Counting epochs without improvement after epoch 5: epoch 6 (1), epoch 7 (2), epoch 8 (3), epoch 9 (4), epoch 10 (5) — patience of 5 is reached at epoch 10, training stops, and the weights saved from epoch 5 (the true best) are restored, discarding the weights from epochs 6–10 that were already drifting into overfitting.

Worked example 2: how patience trades false stops against wasted compute

With patience p=1p=1 on the same sequence: epoch 6 (0.39>0.370.39 > 0.37) is already one epoch without improvement — training stops immediately at epoch 6. That's correct here since epoch 5 really was the best, but on a noisier curve p=1p=1 would frequently stop on a random uptick about to reverse. With patience p=20p=20, training would never trigger the stop within these 10 epochs, wasting compute training a model already past its best point. Patience is a genuine tradeoff: too small risks stopping on noise, too large wastes compute waiting for a stop condition a shorter patience would have caught sooner.

ep61 ep72 ep83 ep94 ep10 → stop5 = patience
Each epoch without a new best validation loss increments the counter; hitting the patience limit at epoch 10 triggers the stop, and the weights from epoch 5 are restored.
training loss validation loss stop here, restore these weights
Training loss keeps falling indefinitely; validation loss turns upward once the model starts overfitting. Early stopping restores the weights from the validation minimum, not from the final epoch.

Early stopping monitors validation loss and halts training once it fails to improve for patience consecutive epochs, then restores the weights from the actual best epoch — not the final one — turning "number of training epochs" from a fixed hyperparameter into something the data itself determines.

What this means in practice

Early stopping is built into every major training framework (EarlyStopping callbacks in Keras, PyTorch Lightning, and similar) and is close to a free regularizer: it costs nothing extra beyond validation evaluation that's usually already being logged. It composes well with other regularization (dropout, weight decay) rather than replacing them, acting as an implicit constraint on how far training is allowed to search the loss landscape.

The common confusion is stopping training at the first epoch where validation loss ticks up, rather than using a patience window and rolling back to the actual best checkpoint. Because validation loss is noisy, a patience of 0 stops on essentially the first bad roll of the dice and both discards a model that may have kept improving, and — just as commonly overlooked — forgetting to restore the best checkpoint means the final saved model is the one from the last epoch trained, which is by construction already past the point early stopping was trying to protect against.

Related concepts

Practice in interviews

Further reading

  • Prechelt, Early Stopping — But When? (1998)
ShareTwitterLinkedIn