Solved by albanD in post #2 
              
              
                Hi, 
.data should never be used. It is doing very dangerous things under the hood and has many unwanted side effects. 
To make operations that are not recorded by the autograd, you should use with torch.no_grad():. 
This is exactly what the nn.init module does as you can seee here for example.