Solved by G.M in post #2 
              
              
                Actually, I believe that it is the abuse of .data which blocked the gradients. .data is deprecated, you should use something like .detach() instead. .data will return the value in a tensor without the gradients and directly setting .data will not change the gradients. In this case, you  should creat…