Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: .fit hook clean up #3198

Merged
merged 4 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pytorch_lightning/trainer/evaluation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,11 @@ def run_evaluation(self, test_mode: bool = False, max_batches=None):
# hook
self.evaluation_loop.on_evaluation_start()

# ------------------------------
# ------------------------------
# ------------------------------
# set up the eval loop
self.evaluation_loop.setup(model, max_batches, dataloaders)

# hook
# TODO: needs to move inside the loop but breaks early stopping
# TODO: should this be insider the dataloader loop?
self.evaluation_loop.on_evaluation_epoch_start()

# run validation/testing
Expand Down Expand Up @@ -300,10 +297,6 @@ def run_evaluation(self, test_mode: bool = False, max_batches=None):
# hook
self.evaluation_loop.on_evaluation_epoch_end()

# ------------------------------
# ------------------------------
# ------------------------------

# log the final eval loop metrics
eval_loop_results = self.__log_evaluation_epoch_metrics(eval_results, test_mode)

Expand Down
14 changes: 5 additions & 9 deletions pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,8 @@ def fit(
# check that model is configured correctly
self.config_validator.verify_loop_configurations(model)

# callbacks
self.on_fit_start(model)
if self.is_function_implemented('on_fit_start', model):
model.on_fit_start()
# hook
self.call_hook('on_fit_start', model)

# on multi-gpu jobs we only want to manipulate (download, etc) on node_rank=0, local_rank=0
# or in the case where each node needs to do its own manipulation in which case just local_rank=0
Expand Down Expand Up @@ -1095,12 +1093,10 @@ def fit(
self.accelerator_backend.setup(model)
results = self.accelerator_backend.train(model)

# on fit end callback
self.on_fit_end()
if self.is_function_implemented('on_fit_end'):
model.on_fit_end()
# hook
self.call_hook('on_fit_end')

# teardown callback
# hook
self.teardown('fit')
if self.is_function_implemented('teardown'):
model.teardown('fit')
Expand Down