Skip to content
Discussion options

You must be logged in to vote

Dear @sebastiangonsal,

From your paper, it seems you might want to call backward which computes the gradients and then add some noise right ?

Therefore, you could override the before_optimizer_step and add noise to all the params.grad.

class TestModel(LightningModule):

    def on_before_optimizer_step(self):
        for param in self.parameters():
            param.grad += torch.rand_like(param.grad)

If you want this re-usable, you could just move this to a callback instead.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by sebastiangonsal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment