Skip to content

Commit 8b50ecf

Browse files
committed
support sanity_val_step=-1
1 parent f8c10fb commit 8b50ecf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pytorch_lightning/trainer/trainer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ def run_pretrain_routine(self, model: LightningModule):
10591059

10601060
# run tiny validation (if validation defined)
10611061
# to make sure program won't crash during val
1062-
if not self.disable_validation and self.num_sanity_val_steps > 0:
1062+
if not self.disable_validation and self.num_sanity_val_steps:
10631063
self.reset_val_dataloader(ref_model)
10641064

10651065
# hook and callback
@@ -1068,6 +1068,7 @@ def run_pretrain_routine(self, model: LightningModule):
10681068

10691069
num_loaders = len(self.val_dataloaders)
10701070
max_batches = [self.num_sanity_val_steps] * num_loaders
1071+
max_batches = [float('inf') for m in max_batches if m == -1]
10711072
eval_results = self._evaluate(model,
10721073
self.val_dataloaders,
10731074
max_batches,

0 commit comments

Comments
 (0)