Skip to content

Commit

Permalink
Fixes #490
Browse files Browse the repository at this point in the history
`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`.
  • Loading branch information
baldassarreFe authored and Borda committed May 25, 2020
1 parent 8ca8336 commit 006a067
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch_lightning/callbacks/early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def on_train_start(self, trainer, pl_module):
self.stopped_epoch = 0
self.best = torch_inf if self.monitor_op == torch.lt else -torch_inf

def on_epoch_end(self, trainer, pl_module):
def on_validation_end(self, trainer, pl_module):
logs = trainer.callback_metrics
stop_training = False
if not self._validate_condition_metric(logs):
Expand Down

0 comments on commit 006a067

Please sign in to comment.