Early stopping when validation is disabled (#1235)

* early stop fallback to train epoch

* added test

* fix imports

* update docs

* update changelog

* fix typo
This commit is contained in:
Adrian Wälchli
2020-03-31 06:24:26 +00:00
committed by GitHub
parent a707d4bea1
commit 1aba411da9
4 changed files with 48 additions and 7 deletions
+12 -3
View File
@@ -4,8 +4,8 @@ Early stopping
Default behavior
----------------
By default early stopping will be enabled if `'val_loss'`
is found in `validation_epoch_end()` return dict. Otherwise
training will proceed with early stopping disabled.
is found in :meth:`~pytorch_lightning.core.lightning.LightningModule.validation_epoch_end`'s
return dict. Otherwise training will proceed with early stopping disabled.
Enable Early Stopping
---------------------
@@ -30,9 +30,18 @@ There are two ways to enable early stopping.
)
trainer = Trainer(early_stop_callback=early_stop_callback)
In any case, the callback will fall back to the training metrics (returned in
:meth:`~pytorch_lightning.core.lightning.LightningModule.training_step`,
:meth:`~pytorch_lightning.core.lightning.LightningModule.training_step_end`)
looking for a key to monitor if validation is disabled or
:meth:`~pytorch_lightning.core.lightning.LightningModule.validation_epoch_end`
is not defined.
Disable Early Stopping
----------------------
To disable early stopping pass ``False`` to the `early_stop_callback`.
To disable early stopping pass ``False`` to the
:paramref:`~pytorch_lightning.trainer.trainer.Trainer.early_stop_callback`.
Note that ``None`` will not disable early stopping but will lead to the
default behaviour.