Solved by ptrblck in post #2 
              
              
                No, you shouldn’t use the .data attribute, as it might yield silent errors and could break your code in various ways. 
The error message points to a mismatch between a tensor and the expected nn.Parameter. 
Try to wrap the new weight into a parameter via: 
with torch.no_grad():
    self.conv.weight …