Solved by albanD in post #2 
              
              
                Hi, 
If you want to change the value of a tensor that requires gradients without it being tracked by the autograd engine, you should do: 
with torch.no_grad():
    a.copy_(b)

As is done for weight initialization for example in the nn.init package. 
If thinks don’t require gradients and have no grad…