michaelklachko:

why is changing p, which is a model parameter, which is the same object as model.conv1.weight, does not change model.conv1.weight?


Because after .clone() in the second loop, p and model.conv1.weight point to different memory, so modifying p doesn’t influence value of model.conv1.weight.
But at the modification between two loops, p and model.conv1.weight still point to the same memory, so changing the value of model.conv1.weght will change the value of p as well.