Solved by ptrblck in post #3 
              
              
                I would not recommend to use the .data attribute, as it might yield unwanted behavior and/or other issues. 
Instead, wrap the parameter manipulation into a with torch.no_grad() block: 
model1 = LeNet(3,16)
a = torch.rand_like(model1.conv1.weight[0]).requires_grad_(True)
a1 = torch.rand_like(model1.c…