added early epoch stopping hook

This commit is contained in:
William Falcon
2019-04-21 12:29:48 -04:00
parent 86261b7404
commit efd750565e
3 changed files with 3 additions and 3 deletions
+2 -1
View File
@@ -267,7 +267,8 @@ class Trainer(TrainerIO):
break
# give model a chance to end epoch early
if self.model.should_stop_epoch():
if self.model.should_stop_epoch:
self.model.should_stop_epoch = False
break
# ---------------
@@ -19,5 +19,3 @@ class ModelHooks(torch.nn.Module):
def on_post_performance_check(self):
pass
def should_stop_epoch(self):
return False
@@ -24,6 +24,7 @@ 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