Solved by KFrank in post #6 
              
              
                Hi Had! 

As an alternative to using a hook, you could write a custom Function 
whose forward() simply passes through the tensor(s) unchanged, but 
whose backward() flips the sign of the gradient(s). 
You would then insert it at the desired place in your network, e.g.: 
out1 = net0 (GradientReversal…