What is the difference between assiging a float value and a tensor value? #545
Unanswered
Endtroducing1993
asked this question in
Q&A
Replies: 1 comment
-
Hi, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Team,
Their are two random tensors that I created:
Tensor A:
tensor([[0.2054, 0.9767, 0.3130, 0.2153],
[0.0492, 0.5223, 0.7216, 0.6107],
[0.5989, 0.1208, 0.0331, 0.5088]])
Tensor B:
tensor([[0.9559, 0.7885, 0.2089, 0.4351],
[0.1314, 0.2588, 0.5905, 0.7723],
[0.9142, 0.0409, 0.8343, 0.1474]])
Now If I assign value 0.9559 to tensor_B in the first row and first column i.e. tensor_B[0,0]=0.2054
then I get the below results:
tensor([[0.9559, 0.9767, 0.3130, 0.2153],
[0.0492, 0.5223, 0.7216, 0.6107],
[0.5989, 0.1208, 0.0331, 0.5088]])
But when I equate them I get all False. I have checked the type also they both are type float32.
tensor_A==tensor_B
tensor([[ False, False, False, False],
[False, False, False, False],
[False, False, False, False]])
But if I do tensor_B[0,0]=tensor_A[0,0]
We get the below result:
tensor([[ True, False, False, False],
[False, False, False, False],
[False, False, False, False]])
Request you to please suggest why are we getting True in one case but False in other. Where the datatype as both torch.float32
Beta Was this translation helpful? Give feedback.
All reactions