8.3. Early Stopping
Early stopping ends training as soon as the validation metric stops improving, which avoids overfitting and saves training time. New in 1.5.0, it is on by default for every time series task type (classification, regression, anomaly detection, forecasting) and for image classification.
8.3.1. Configuration
The three keys live in the training section of the config YAML:
Key |
Default |
Meaning |
|---|---|---|
|
|
Enable or disable early stopping. |
|
|
Number of consecutive epochs without improvement before training stops. |
|
|
Minimum change in the monitored metric that counts as an improvement. |
training:
training_epochs: 100
early_stopping: True
early_stopping_patience: 5
early_stopping_min_delta: 0.0
To always train for the full number of epochs, set early_stopping: False.
8.3.2. How it works
After each validation pass the training script reports the monitored metric. An epoch counts as
an improvement only if the metric is better than the best value so far by more than
early_stopping_min_delta. Otherwise the counter of bad epochs increases, and when it reaches
early_stopping_patience training stops and the log shows
Early stopping at epoch N: no improvement for <patience> epochs.
The best model found so far is the one that is kept, as in a normal run.
The monitored metric depends on the task type:
Task type |
Monitored metric |
Better when |
|---|---|---|
Classification (time series, image) |
Validation accuracy |
higher |
Regression |
Validation MSE |
lower |
Anomaly detection |
Validation MSE (reconstruction error) |
lower |
Forecasting |
Validation SMAPE |
lower |
Tip
With a large training_epochs value, the default patience of 5 is usually enough. If your validation
curve is noisy (small datasets), raise early_stopping_patience or set a small
early_stopping_min_delta instead of disabling early stopping.
Note
The audio and radar classification training scripts in 1.5.0 accept the same three keys in their parameter set but do not apply early stopping in their training loop.
See How to Create a ModelZoo Config YAML for the rest of the training keys.