Hello,
I have 2 models (M1 and M2), with two losses L1 and L2. Not to mention 2 optimizers.
The output from M1 is fed as an input to M2, which makes M1 part of the computational graph of M2 (right?)
Consequently, the parameters of M1 will receive gradient signal from L2 (loss of the second model). I would like to prevent this from happening, i.e. M1 only learns from L1 and M2 only learns from L2. How can I do this?
I am guessing that I need to use a detach() somewhere (like in the DCGAN example), but I really don’t know where exactly. (I had a previous question on how detach() works and I am still not super clear)
Any help would be greatly appreciated.
Thanks,
Gautam