Shortcuts

EarlyStopping

class pytorch_lightning.callbacks.EarlyStopping(monitor='early_stop_on', min_delta=0.0, patience=3, verbose=False, mode='auto', strict=True)[source]

Bases: pytorch_lightning.callbacks.base.Callback

Monitor a validation metric and stop training when it stops improving.

Parameters
  • monitor (str) – quantity to be monitored. Default: 'early_stop_on'.

  • min_delta (float) – 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 (int) – number of validation epochs with no improvement after which training will be stopped. Default: 3.

  • verbose (bool) – verbosity mode. Default: False.

  • mode (str) – one of {auto, min, max}. In min mode, training will stop when the quantity monitored has stopped decreasing; in max mode it will stop when the quantity monitored has stopped increasing; in auto mode, the direction is automatically inferred from the name of the monitored quantity. Default: 'auto'.

  • strict (bool) – whether to crash the training if monitor is not found in the validation metrics. Default: True.

Example:

>>> from pytorch_lightning import Trainer
>>> from pytorch_lightning.callbacks import EarlyStopping
>>> early_stopping = EarlyStopping('val_loss')
>>> trainer = Trainer(callbacks=[early_stopping])
on_load_checkpoint(checkpointed_state)[source]

Called when loading a model checkpoint, use to reload state.

on_save_checkpoint(trainer, pl_module)[source]

Called when saving a model checkpoint, use to persist state.

on_train_epoch_end(trainer, pl_module, outputs)[source]

Called when the train epoch ends.

on_validation_end(trainer, pl_module)[source]

Called when the validation loop ends.

on_validation_epoch_end(trainer, pl_module)[source]

Called when the val epoch ends.

Read the Docs v: 1.0.7
Versions
latest
stable
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3.2
0.5.3
0.4.9
release-1.0.x
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.