I’m new to pytorch. I see some code which always calls .data to indirectly update a tensor, an example is
the moving average for the target network in DQN
If you use .data autograd doesn’t track these changes and you might end up with wrong gradients, as you are modifying the underlying data.
If you want to update a parameter like weight, you should use the new with torch.no_grad() op, as it’s generally not advised to use .data.
Based on what you said, it seems that .data is the same as the tensor itself. I want to know whether it is necessary to use .data anymore since pytorch 4.0 has deprecated variable?