Vahid is right that in the case of his example
self.conv1.weight.data = self.conv1.weight.data + K

this will work because “weight” is already a parameter, and you are just modifying its value. But if you want to assign a completely new tensor to “weight” you would need wrap Parameter around that to get correct behavior.