I used function id() to check the reference of an element of a torch tensor and found it was changing all the time. But if I check the id() of an element in a list, it is stable. I just wonder why is this?
The code is below:
import torch
…: a = torch.tensor([0,1,2,3])
…: b = [0,1,2,3]
…:
id(a[0])
Out[16]: 140023032068568
id(a[0])
Out[17]: 140023032095656
id(a[0])
Out[18]: 140023032069288
id(b[0])
Out[19]: 94672250583712
id(b[0])
Out[20]: 94672250583712
id(b[0])
Out[21]: 94672250583712
id(a)
Out[22]: 140024314842496
id(a)
Out[23]: 140024314842496
id(a)
Out[24]: 140024314842496