Gradient Manipulation for Multitask Learning #12810
Unanswered
haldunbalim
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I would like to implement the paper "Adapting Auxiliary Losses Using Gradient Similarity". Where I have a main loss and multiple different auxiliary losses and would pass these auxiliary losses to optimizer if the gradients have cosine similarity over zero with the main task loss. For this I calculate gradients with respect to each loss using torch.autograd.grad and calculate cosine similarities and add only the selected task losses to optimized loss. However, since I don’t know how to pass these gradients to optimizer I calculate the backwards two times every step. I would like to learn how to implement this in an effective way.
Thanks a lot.
Beta Was this translation helpful? Give feedback.
All reactions