Why the tensor has been changed when I change the array? I'm confused! #124
-
Converting an array to a tensorInput:
Output:
But in this case, everything is okay:Input:
Output:
And again, the tensor has been changed when I change the array :Input:
Output:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I had the same doubt when going through the video; the point should be the following:
i.e. modifications to the numpy array from which the torch tensor is created get reflected into the tensor itself (as in your first and third example).
|
Beta Was this translation helpful? Give feedback.
I had the same doubt when going through the video; the point should be the following:
i.e. modifications to the numpy array from which the torch tensor is created get reflected into the tensor itself (as in your first and third example).
On the other hand, as explained in https://stackoverflow.com/questions/48370286/pytorch-updating-numpy-array-not-updating-the-corresponding-tensor, in your second example you're creating a brand new array, which is why the update doesn't get reflected in the torch tensor. For…