I have a kind of specific problem that I can’t seem to figure out.  I have created a custom nn.Module mod1.  This module contains a conv2d and a second nn.Module mod2 which also contains a conv2d.  The calculation process is for mod1 to do a conv2d then sigmoid on its input, mod2 to do a conv2d then sigmoid on its input, then to add those two values together.
I am using a backward hook to track the grad_in and grad_out of mod1.  If I do not add mod2’s value grad_in is the inverse sigmoid * grad_out as it should be.  If I just return mod2s output value on its own mod1’s grad_in is (inverse sigmoid of mod2)* grad_out.  However if I add the two values together like I need to do grad_in just contains two copies of grad_out.