Skip to content

How to access validation step outputs of complete epoch in a on_validation_epoch_end hook for a custom callback ? #11659

Discussion options

You must be logged in to vote

hey @Gladiator07!

you can either override on_validation_batch_end hook and cache the outputs in some variable of the callback use that.

class CustomCallback(Callback):
    def __init__(self):
        self.val_outs = []
    def on_validation_batch_end(self, trainer, pl_module, outputs, ...):
        self.val_outs.append(outputs)

    def on_validation_epoch_end(self, trainer, pl_module):
        self.val_outs  # <- access them here

or cache the val outputs in pl_module inside validation_epoch_end

class LitModel(LightningModule):
    def validation_epoch_end(self, outputs):
       new_outputs = ...
       self.val_outs = new_outputs


class CustomCallback(Callback):
    def on_validation_ep…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zhiyang-fu
Comment options

Answer selected by Gladiator07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment