Skip to content
Discussion options

You must be logged in to vote

The best is to use manual optimization:
https://pytorch-lightning.readthedocs.io/en/latest/common/optimizers.html#manual-optimization

Then you have control over each optimizer step.

You can get the optimzers with self.optimizers()
and for backward you simply have to replace loss.backward() with self.manual_backward(loss)
Make sure you use the latest version of Lightning for that for optimal support.

Hope this helps

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@stdoo
Comment options

@akihironitta
Comment options

@awaelchli
Comment options

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