Gulzar
Gulzar

Reputation: 27946

What is the difference between `on_validation_epoch_end` and `validation_epoch_end` in Pytorch-lightning?

Inside a LightningModule,Pycharm allows 2 auto complete methods:

class MyModel(LightningModule):

    def on_validation_epoch_end(self):

    def validation_epoch_end(self, outs):

with on_validation_epoch_end referenced in hooks.py

def on_validation_epoch_end(self) -> None:
    """
    Called in the validation loop at the very end of the epoch.
    """
    # do something when the epoch ends

and

validation_epoch_end called in evaluation_loop.py as eval_results = model.validation_epoch_end(eval_results) leading to __run_eval_epoch_end.


What is the purpose of each of those?

I can only assume one is deprecated. Could not find any relevant docs.

Upvotes: 8

Views: 9892

Answers (1)

trialNerror
trialNerror

Reputation: 3553

Here is a pseudocode that shows when the hooks are called, and I think it makes it quite explicit that you are right : these two functions are redundant (literally called at the same place with the same arguments) and I would say that validation_epoch_end is the one to be considered deprecated here, since it's not mentioned in the doc whereas the hooks (of the form on_event_start/end) are extensively explained

Upvotes: 5

Related Questions