What is early stopping?

Last updated 3 November 2026

Early stopping halts training when performance on a held-out validation set stops improving, then keeps the best checkpoint. It regularizes by limiting how far the optimizer can move from its initialization toward fitting noise.

  • How it works:

    1. Evaluate a validation metric (usually loss) after each epoch or every N steps.

    2. Track the best value seen so far. If it hasn't improved by at least min_delta for patience evaluations, stop.

    3. Restore the best weights rather than the last ones.

  • Why it regularizes:

    • Training error keeps falling, but validation error forms a U-shape once the model starts memorizing. Stopping at the minimum picks the bias-variance sweet spot.

    • For a linear model with quadratic loss trained by gradient descent from zero, stopping after τ steps behaves like L2 regularization with λ ≈ 1/(ητ).

  • Pros:

    • Nearly free, and it also saves compute.

    • It tunes the effective capacity automatically.

  • Cons:

    • It consumes validation data.

    • Noisy metrics need a sensible patience setting.

    • Repeated checking can overfit the validation set.

    • It interacts with LR schedules: a loss plateau before an LR drop can trigger a premature stop.

    • Under double descent, validation loss can improve again later.

  • Common variant: find the best epoch count, then retrain on train plus validation data for that many epochs.

[lang:python] cb = keras.callbacks.EarlyStopping(monitor="val_loss", patience=5, restore_best_weights=True) model.fit(X, y, validation_split=0.2, epochs=200, callbacks=[cb])

  • https://medium.com/@coder_cat/nail-your-data-science-interview-day-4-regularization-techniques-7dae7cc71279
  • https://www.techinterview.org/post/3233459982/overfitting-regularization/
  • https://medium.com/@juanc.olamendy/understanding-early-stopping-a-key-to-preventing-overfitting-in-machine-learning-17554fc321ff
All Regularization interview questions