Solved by ptrblck in post #2 
              
              
                Don’t use the .data attribute as it’s deprecated and could yield any side effects. 
Instead, wrap the code in a with torch.no_grad() block and assign new nn.Parameters to the module parameters or use m.param.copy_ instead.