Early Stopping
- class neuro_fuzzy_toolbox.training.early_stopping.EarlyStopping(patience, delta=0, last_state=False)[source]
Bases:
objectEarly stopping mechanism for halting the training of a machine learning model (
torch.nn.Module) when no sufficient improvement is observed.- __call__(model, loss, verbose=False)[source]
Evaluates whether training should be stopped. If the stopping criterion is met, the
stopattribute is updated toTrue.- Parameters:
model (torch.nn.Module) – Model to evaluate.
loss (float) – Current loss value of the model.
verbose (bool) – If
True, prints a warning message when early stopping is triggered. Defaults toFalse.
- __init__(patience, delta=0, last_state=False)[source]
Initializes a new EarlyStopping instance.
- Parameters:
patience (int) – Number of epochs without improvement before stopping training.
delta (float) – Minimum improvement required to consider that the model has improved. Defaults to
0.last_state (bool) – If
True, restores the last model state when stopping instead of the best state found during training. Defaults toFalse.
- property stop
Indicates whether training should be stopped.
- Returns:
Trueif the stopping criterion has been met,Falseotherwise.- Return type:
bool