Skip to content

TypeError: on_validation_end() missing 1 required positional argument: 'outputs' #17182

Answered by AzulGarza
dimgag asked this question in code help: CV
Discussion options

You must be logged in to vote

hey @dimgag! I had the same problem recently. As of lightning>=2.0.0 you have to define the validation_step_outputs in the init clause of your module to store the validation outputs of each epoch. Here's an example (from this PR).

 class MyLightningModule(L.LightningModule):
    def __init__(self):
        super().__init__()
        self.validation_step_outputs = []

     def validation_step(self, ...):
         loss = ...
         self.validation_step_outputs.append(loss)
         return loss

    def on_validation_epoch_end(self):
        epoch_average = torch.stack(self.validation_step_outputs).mean()
        self.log("validation_epoch_average", epoch_average)
        self.validation_s…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dimgag
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants