Update `EarlyStopping` docs (#7121)

This commit is contained in:
Adrian Wälchli 2021-04-21 01:23:36 +02:00 committed by GitHub
parent 013756404b
commit e4f3a8d3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -34,7 +34,7 @@ callback can be used to monitor a validation metric and stop the training when n
To enable it:
- Import :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` callback.
- Log the metric you want to monitor using :func:`~~pytorch_lightning.core.lightning.LightningModule.log` method.
- Log the metric you want to monitor using :func:`~pytorch_lightning.core.lightning.LightningModule.log` method.
- Init the callback, and set `monitor` to the logged metric of your choice.
- Pass the :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping` callback to the :class:`~pytorch_lightning.trainer.trainer.Trainer` callbacks flag.
@ -47,7 +47,7 @@ To enable it:
trainer = Trainer(callbacks=[EarlyStopping(monitor='val_loss')])
- You can customize the callbacks behaviour by changing its parameters.
You can customize the callbacks behaviour by changing its parameters.
.. testcode::
@ -60,6 +60,15 @@ To enable it:
)
trainer = Trainer(callbacks=[early_stop_callback])
Additional parameters that stop training at extreme points:
- ``stopping_threshold``: Stops training immediately once the monitored quantity reaches this threshold.
It is useful when we know that going beyond a certain optimal value does not further benefit us.
- ``divergence_threshold``: Stops training as soon as the monitored quantity becomes worse than this threshold.
When reaching a value this bad, we believe the model cannot recover anymore and it is better to stop early and run with different initial conditions.
- ``check_finite``: When turned on, we stop training if the monitored metric becomes NaN or infinite.
In case you need early stopping in a different part of training, subclass :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping`
and change where it is called:
@ -91,9 +100,3 @@ and change where it is called:
.. seealso::
- :class:`~pytorch_lightning.trainer.trainer.Trainer`
- :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping`
----------
.. seealso::
- :class:`~pytorch_lightning.trainer.trainer.Trainer`
- :class:`~pytorch_lightning.callbacks.early_stopping.EarlyStopping`