Use `trainer.call_hook` in the evaluation loop (#7626)

This commit is contained in:
Carlos Mocholí 2021-05-21 12:54:52 +02:00 committed by GitHub
parent 3d4dd28bec
commit 603ef2cf7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 16 deletions

View File

@ -250,21 +250,6 @@ class EvaluationLoop(object):
self.trainer.dev_debugger.track_eval_loss_history(batch_idx, dataloader_idx, output)
def on_evaluation_epoch_end(self) -> None:
model_ref = self.trainer.lightning_module
hook_name = "on_test_epoch_end" if self.trainer.testing else "on_validation_epoch_end"
self.trainer._reset_result_and_set_fx_name(hook_name)
with self.trainer.profiler.profile(hook_name):
if hasattr(self.trainer, hook_name):
on_evaluation_epoch_end_hook = getattr(self.trainer, hook_name)
on_evaluation_epoch_end_hook()
if is_overridden(hook_name, model_ref):
model_hook_fx = getattr(model_ref, hook_name)
model_hook_fx()
self.trainer._cache_logged_metrics()
self.trainer.call_hook(hook_name)
self.trainer.call_hook('on_epoch_end')