avalanche.training.plugins.EarlyStoppingPlugin
- class avalanche.training.plugins.EarlyStoppingPlugin(patience: int, val_stream_name: str, metric_name: str = 'Top1_Acc_Stream', mode: str = 'max')[source]
Early stopping plugin.
Simple plugin stopping the training when the accuracy on the corresponding validation metric stopped progressing for a few epochs. The state of the best model is saved after each improvement on the given metric and is loaded back into the model before stopping the training procedure.
- __init__(patience: int, val_stream_name: str, metric_name: str = 'Top1_Acc_Stream', mode: str = 'max')[source]
- Parameters
patience – Number of epochs to wait before stopping the training.
val_stream_name – Name of the validation stream to search in the
metrics. The corresponding stream will be used to keep track of the evolution of the performance of a model. :param metric_name: The name of the metric to watch as it will be reported in the evaluator. :param mode: Must be “max” or “min”. max (resp. min) means that the given metric should me maximized (resp. minimized).
Methods
__init__(patience, val_stream_name[, ...])- param patience
Number of epochs to wait before stopping the training.
after_backward(strategy, **kwargs)Called after criterion.backward() by the BaseStrategy.
after_eval(strategy, **kwargs)Called after eval by the BaseStrategy.
after_eval_dataset_adaptation(strategy, **kwargs)Called after eval_dataset_adaptation by the BaseStrategy.
after_eval_exp(strategy, **kwargs)Called after eval_exp by the BaseStrategy.
after_eval_forward(strategy, **kwargs)Called after model.forward() by the BaseStrategy.
after_eval_iteration(strategy, **kwargs)Called after the end of an iteration by the BaseStrategy.
after_forward(strategy, **kwargs)Called after model.forward() by the BaseStrategy.
after_train_dataset_adaptation(strategy, ...)Called after train_dataset_adapatation by the BaseStrategy.
after_training(strategy, **kwargs)Called after train by the BaseStrategy.
after_training_epoch(strategy, **kwargs)Called after train_epoch by the BaseStrategy.
after_training_exp(strategy, **kwargs)Called after train_exp by the BaseStrategy.
after_training_iteration(strategy, **kwargs)Called after the end of a training iteration by the BaseStrategy.
after_update(strategy, **kwargs)Called after optimizer.update() by the BaseStrategy.
before_backward(strategy, **kwargs)Called before criterion.backward() by the BaseStrategy.
before_eval(strategy, **kwargs)Called before eval by the BaseStrategy.
before_eval_dataset_adaptation(strategy, ...)Called before eval_dataset_adaptation by the BaseStrategy.
before_eval_exp(strategy, **kwargs)Called before eval_exp by the BaseStrategy.
before_eval_forward(strategy, **kwargs)Called before model.forward() by the BaseStrategy.
before_eval_iteration(strategy, **kwargs)Called before the start of a training iteration by the BaseStrategy.
before_forward(strategy, **kwargs)Called before model.forward() by the BaseStrategy.
before_train_dataset_adaptation(strategy, ...)Called before train_dataset_adapatation by the BaseStrategy.
before_training(strategy, **kwargs)Called before train by the BaseStrategy.
before_training_epoch(strategy, **kwargs)Called before train_epoch by the BaseStrategy.
before_training_exp(strategy, **kwargs)Called before train_exp by the BaseStrategy.
before_training_iteration(strategy, **kwargs)Called before the start of a training iteration by the BaseStrategy.
before_update(strategy, **kwargs)Called before optimizer.update() by the BaseStrategy.