I am trying to perform logical element-wise opertaions on tensors, but it seems "and" keyword performs logical or, while "or" keyword performs logical and :
a = torch.zeros(3)
a[1] = 1 -- a will be [1,0,0]
b = torch.ones(3)
b[3] = 0 -- b will be [1,1,0]
c = torch.eq(a,1) and torch.eq(b,1)
d = torch.eq(a,1) or torch.eq(b,1)
I was expecting c to become [1,0,0]
since it would make sense to have 1 only in positions where both a and b are equal to 1. Also I was expecting d to become [1,1,0]
since those are the positions where either a or b are equal to 1. To my surprise, the results are completely the opposite!
Any explanations?