I am accidentally using in
operator to check whether a two-dimensional torch contains a single vector. But the results are not the same as expected?
Intuitively, test 2 3 4 should also fail but they didn’t.
My platform: windows 10, torch1.12.0+cpu.
import torch
b = torch.LongTensor([
[1, 2, 3],
[4, 5, 6],
])
# test 1
assert torch.LongTensor([1, 2, 3]) in b # pass as expected
# test 2
assert torch.LongTensor([1, 2, 4]) in b # why pass ?
# test 3
assert torch.LongTensor([1, 2, 8]) in b # why pass ?
# test 4
assert torch.LongTensor([2, 2, 6]) in b # why pass ?
# test 5
assert torch.LongTensor([8, 8, 8]) in b # fail as expected