Skip to content

Commit b35c472

Browse files
kuynzerebwilliamFalcon
authored andcommitted
early stopping check_val_every_n_epoch fix (#743)
1 parent 946aef6 commit b35c472

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pytorch_lightning/trainer/training_loop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def train(self):
296296
self.current_epoch = epoch
297297

298298
total_val_batches = 0
299+
is_val_epoch = False
299300
if not self.disable_validation:
300301
# val can be checked multiple times in epoch
301302
is_val_epoch = (self.current_epoch + 1) % self.check_val_every_n_epoch == 0
@@ -346,7 +347,7 @@ def train(self):
346347

347348
# early stopping
348349
met_min_epochs = epoch >= self.min_epochs - 1
349-
if (self.enable_early_stop and not self.disable_validation and
350+
if (self.enable_early_stop and not self.disable_validation and is_val_epoch and
350351
(met_min_epochs or self.fast_dev_run)):
351352
should_stop = self.early_stop_callback.on_epoch_end(epoch=epoch,
352353
logs=self.callback_metrics)

0 commit comments

Comments
 (0)