Skip to content

Commit

Permalink
early stopping check_val_every_n_epoch fix (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuynzereb authored and williamFalcon committed Jan 24, 2020
1 parent 946aef6 commit b35c472
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pytorch_lightning/trainer/training_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def train(self):
self.current_epoch = epoch

total_val_batches = 0
is_val_epoch = False
if not self.disable_validation:
# val can be checked multiple times in epoch
is_val_epoch = (self.current_epoch + 1) % self.check_val_every_n_epoch == 0
Expand Down Expand Up @@ -346,7 +347,7 @@ def train(self):

# early stopping
met_min_epochs = epoch >= self.min_epochs - 1
if (self.enable_early_stop and not self.disable_validation and
if (self.enable_early_stop and not self.disable_validation and is_val_epoch and
(met_min_epochs or self.fast_dev_run)):
should_stop = self.early_stop_callback.on_epoch_end(epoch=epoch,
logs=self.callback_metrics)
Expand Down

0 comments on commit b35c472

Please sign in to comment.