Skip to content

Commit

Permalink
Improved EarlyStopping.patience documentation (#6278)
Browse files Browse the repository at this point in the history
* Improved early stopping documentation

* Changed to 120 column format

* doc

* doc

* doc

Co-authored-by: Jirka Borovec <jirka.borovec@seznam.cz>
  • Loading branch information
turian and Borda committed Mar 2, 2021
1 parent eb81500 commit 22985d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion notebooks/05-trainer-flags-overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@
"id": "7TAIerPYe_Q1"
},
"source": [
"The EarlyStopping callback runs at the end of every validation epoch, which, under the default configuration, happens after every training epoch. However, the frequency of validation can be modified by setting various parameters on the Trainer, for example check_val_every_n_epoch and val_check_interval. It must be noted that the patience parameter counts the number of validation epochs with no improvement, and not the number of training epochs. Therefore, with parameters check_val_every_n_epoch=10 and patience=3, the trainer will perform at least 40 training epochs before being stopped."
"The EarlyStopping callback runs at the end of every validation check, which, under the default configuration, happens after every training epoch. However, the frequency of validation can be modified by setting various parameters on the Trainer, for example check_val_every_n_epoch and val_check_interval. It must be noted that the patience parameter counts the number of validation checks with no improvement, and not the number of training epochs. Therefore, with parameters check_val_every_n_epoch=10 and patience=3, the trainer will perform at least 40 training epochs before being stopped."
]
},
{
Expand Down
34 changes: 19 additions & 15 deletions pytorch_lightning/callbacks/early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,26 @@ class EarlyStopping(Callback):
Monitor a metric and stop training when it stops improving.
Args:
monitor: quantity to be monitored. Default: ``'early_stop_on'``.
min_delta: minimum change in the monitored quantity
to qualify as an improvement, i.e. an absolute
change of less than `min_delta`, will count as no
improvement. Default: ``0.0``.
patience: number of validation epochs with no improvement
after which training will be stopped. Default: ``3``.
verbose: verbosity mode. Default: ``False``.
mode: one of ``'min'``, ``'max'``. In ``'min'`` mode,
training will stop when the quantity
monitored has stopped decreasing and in ``'max'``
mode it will stop when the quantity
monitor: quantity to be monitored.
min_delta: minimum change in the monitored quantity to qualify as an improvement, i.e. an absolute
change of less than `min_delta`, will count as no improvement.
patience: number of validation checks with no improvement
after which training will be stopped. Under the default configuration, one validation check happens after
every training epoch. However, the frequency of validation can be modified by setting various parameters on
the ``Trainer``, for example ``check_val_every_n_epoch`` and ``val_check_interval``.
.. note::
It must be noted that the patience parameter counts the number of validation checks with
no improvement, and not the number of training epochs. Therefore, with parameters
``check_val_every_n_epoch=10`` and ``patience=3``, the trainer will perform at least 40 training
epochs before being stopped.
verbose: verbosity mode.
mode: one of ``'min'``, ``'max'``. In ``'min'`` mode, training will stop when the quantity
monitored has stopped decreasing and in ``'max'`` mode it will stop when the quantity
monitored has stopped increasing.
strict: whether to crash the training if `monitor` is
not found in the validation metrics. Default: ``True``.
strict: whether to crash the training if `monitor` is not found in the validation metrics.
Raises:
MisconfigurationException:
Expand Down

0 comments on commit 22985d2

Please sign in to comment.