how to check for example if:
torch.tensor([1, 3]) belongs to torch.tensor([3, 1], [1, 1], [3, 1])
a in b methods compare element-wise and thus here not correct
what I want to compute is whether the whole tensor [1, 3] is in the bigger one
thanks
how to check for example if:
torch.tensor([1, 3]) belongs to torch.tensor([3, 1], [1, 1], [3, 1])
a in b methods compare element-wise and thus here not correct
what I want to compute is whether the whole tensor [1, 3] is in the bigger one
thanks
we illustreate the answer with the following example:
a = torch.tensor([[4,5],[2,3], [5,3]])
b = torch.tensor([[1,2], [2,3],[3,4],[7,7],[3,5]])
result = []
for i in a:
try: # to avoid error for the case of empty tensors
result.append(max(i.numpy()[1] == b.T.numpy()[1,i.numpy()[0] == b.T.numpy()[0,:]]))
except:
result.append(False)
result
output will show: [False, True, False]