What is the difference between computing on tensor and tensor.data

Hi,

I noticed in some code that some people like to compute on the tensor.data, what is its difference compared to compute directly on tensor?

backup = {}
for name, param in model.named_parameters():
    backup[name] = param.data.clone() # other people's code
    backup[name] = param.clone().detach()  # my implementation if I am on this task

The usage of .data might yield silent errors and is thus not recommended.
.clone().detach() should work fine, so please stick to your approach. :wink: