Hi Hoang!



 hoangcuong2011:


a = torch.rand(2, 10)
tensor([[0.7576, 0.2793, 0.4031, 0.7347, 0.0293, 0.7999, 0.3971,
…



Here a is only printed out to four decimal digits.  That is, a[0][0]
is a number close to, but not actually equal to 0.7576.  Perhaps
a[0][0] = 0.75758379.



a != 0.7576



Here you compare a[0][0] (as well as the rest of a) with 0.7576.
But a[0][0] is only approximately equal 0.7576 (equal only to four
decimal digits).  Because it is not exactly equal, the inequality (!=)
test returns True (as it should).



a != a[0][0]
tensor([[False, True, True, True, True, True, True,
…



Now you are comparing a to a[0][0] (in our hypothetical example, to
0.75758379).  a[0][0] is, after all, exactly equal to a[0][0], so the
inequality test returns False, as you expect.
Best.
K. Frank