I agree, i costs me some time to find the problem caused by that.
The same here: https://stackoverflow.com/questions/48482787/pytorch-memory-model-torch-from-numpy-vs-torch-tensor
arr = np.arange(10, dtype=np.float32).reshape(5, 2)
t0 = torch.Tensor(arr)
t1 = torch.tensor(arr)
t2 = torch.from_numpy(arr)
arr
t0
t1
t2
t2[:, 1] = 23.0
arr
t0
t1
t2
arr
array([[ 0., 23.],
[ 2., 23.],
[ 4., 23.],
[ 6., 23.],
[ 8., 23.]], dtype=float32)
t0
tensor([[ 0., 23.],
[ 2., 23.],
[ 4., 23.],
[ 6., 23.],
[ 8., 23.]])
t1
tensor([[0., 1.],
[2., 3.],
[4., 5.],
[6., 7.],
[8., 9.]])
t2
tensor([[ 0., 23.],
[ 2., 23.],
[ 4., 23.],
[ 6., 23.],
[ 8., 23.]])
It’s confusing when your wife’s name is Katja, but you call her Tanja right? Unclear side effects are possible in both cases …
Searching for “torch tensor” can lead to different results containing torch.tensor and torch.Tensor results as well…