a = torch.tensor( [10,2,5,1,9,7,8] )
b = torch.tensor( [1,9,8] )
I want to remove the same numbers as b from a.
What is the fastest way to do it?
The result tensor can be sorted or unsorted.
i.e. the result c is:
torch.tensor( [10,2,5,7] )
or
torch.tensor( [2,5,7,10] )
I can do this by:
from collections import Counter
ca = Counter(a.numpy())
cb = Counter(b.numpy())
c = torch.tensor( list( (ca-cb).elements() ) )
But, I am wondering if there is a better(faster) way to do it.