added early epoch stopping hook

This commit is contained in:
William Falcon
2019-04-21 12:30:54 -04:00
parent efd750565e
commit 76cc1c6eab
3 changed files with 3 additions and 3 deletions
+1 -2
View File
@@ -267,8 +267,7 @@ class Trainer(TrainerIO):
break
# give model a chance to end epoch early
if self.model.should_stop_epoch:
self.model.should_stop_epoch = False
if self.model.should_stop_epoch(data_batch):
break
# ---------------
@@ -19,3 +19,5 @@ class ModelHooks(torch.nn.Module):
def on_post_performance_check(self):
pass
def should_stop_epoch(self, data_batch):
return False
@@ -24,7 +24,6 @@ class RootModule(GradInformation, ModelIO, OptimizerConfig, ModelHooks):
self.overfit = hparams.overfit
self.gradient_clip = hparams.gradient_clip
self.num = 2
self.should_stop_epoch = False
# track if gpu was requested for checkpointing
self.on_gpu = False