EarlyStoppingCallback
Module implementing early stopping functionality for model training.
This module provides an early stopping callback that monitors a metric during training and stops the training process if no improvement is seen for a specified number of evaluations. This helps prevent overfitting by stopping training when the model performance plateaus or starts to degrade on validation data.
EarlyStoppingCallback
¶
Callback to implement early stopping during training.
ATTRIBUTE | DESCRIPTION |
---|---|
patience |
Number of evaluations with no improvement after which training will be stopped.
TYPE:
|
min_delta |
Minimum change in the monitored metric to qualify as an improvement.
TYPE:
|
best_score |
Best score observed so far.
TYPE:
|
counter |
Number of consecutive evaluations with no improvement.
TYPE:
|
stop_training |
Flag to indicate whether to stop training.
TYPE:
|
Source code in src/training/common/early_stopping.py
on_evaluate
¶
Evaluate current score and update early stopping state.
PARAMETER | DESCRIPTION |
---|---|
score
|
Current evaluation score to compare against best score
TYPE:
|
epoch
|
Current training epoch number
TYPE:
|
steps
|
Current training step number
TYPE:
|
This method compares the current score against the best score seen so far. If the score does not improve by at least min_delta for patience number of evaluations, it sets stop_training to True.