Solved by albanD in post #2 
              
              
                Hi, 
Few things: 

You can replace this to be more efficient:

diff_loss.backward()
likelihood_loss.backward()

by 
(diff_loss + likelihood_loss).backward()


When you do list(foo.parameters()), you get a reference to the weights. So if you change them to not require gradients, then you basically ch…