Skip to content

Commit 006a067

Browse files
baldassarreFeBorda
authored andcommitted
Fixes #490
`EarlyStopping` should check the metric of interest `on_validation_end` rather than `on_epoch_end`. In a normal scenario, this does not cause a problem, but in combination with `check_val_every_n_epoch>1` in the `Trainer` it results in a warning or in a `RuntimeError` depending on `strict`.
1 parent 8ca8336 commit 006a067

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytorch_lightning/callbacks/early_stopping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def on_train_start(self, trainer, pl_module):
109109
self.stopped_epoch = 0
110110
self.best = torch_inf if self.monitor_op == torch.lt else -torch_inf
111111

112-
def on_epoch_end(self, trainer, pl_module):
112+
def on_validation_end(self, trainer, pl_module):
113113
logs = trainer.callback_metrics
114114
stop_training = False
115115
if not self._validate_condition_metric(logs):

0 commit comments

Comments
 (0)