Hi, I have a quick question about how to calculate the specific indices of elements which are in one tensor but not in the other tensor.
What I want to do is
a = torch.Tensor([1, 2, 3, 4])
b = torch.Tensor([2, 3])
indice = []
for i in range(len(a)):
in_b = False
for j in range(len(b)):
if a[i] == b[j]:
in_b = True
if not in_b:
indice.append(i)
print(indice) # now, it gives us 0, 3 because the element 1, 4 in a are not in b.
I’m wondering if there is more efficient solution to do this? Thanks!