mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-14 11:33:33 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
333f0fde9b | ||
|
|
4b0b7e5ea3 | ||
|
|
e89da15f18 |
@@ -86,7 +86,7 @@ class Trainer(TrainerIO):
|
||||
self.test_percent_check = overfit_pct
|
||||
|
||||
def __is_function_implemented(self, f_name):
|
||||
f_op = getattr(self, f_name, None)
|
||||
f_op = getattr(self.model, f_name, None)
|
||||
return callable(f_op)
|
||||
|
||||
@property
|
||||
@@ -266,10 +266,6 @@ class Trainer(TrainerIO):
|
||||
if met_batch_limit:
|
||||
break
|
||||
|
||||
# give model a chance to end epoch early
|
||||
if self.model.should_stop_epoch(data_batch):
|
||||
break
|
||||
|
||||
# ---------------
|
||||
# RUN TRAIN STEP
|
||||
# ---------------
|
||||
@@ -331,7 +327,9 @@ class Trainer(TrainerIO):
|
||||
|
||||
# hook
|
||||
if self.__is_function_implemented('on_batch_start'):
|
||||
self.model.on_batch_start()
|
||||
response = self.model.on_batch_start(data_batch)
|
||||
if response == -1:
|
||||
return
|
||||
|
||||
if self.enable_tqdm:
|
||||
self.prog_bar.update(1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import torch
|
||||
|
||||
class ModelHooks(torch.nn.Module):
|
||||
def on_batch_start(self):
|
||||
def on_batch_start(self, data_batch):
|
||||
pass
|
||||
|
||||
def on_batch_end(self):
|
||||
@@ -19,5 +19,3 @@ class ModelHooks(torch.nn.Module):
|
||||
def on_post_performance_check(self):
|
||||
pass
|
||||
|
||||
def should_stop_epoch(self, data_batch):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user