mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-09 11:32:07 +08:00
added early epoch stopping hook
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user