Is there pytorch function which is similar to numpy.in1d?

Hi everyone,

I would like to compare the two arrays whether the element in one array exists in the other array especially for the one dimensional array which works same as numpy.in1d.
Is there any pytorch function corresponding to this?

1 Like

Here’s what you want:

1 Like

Thank you very much!

Hi, I checked the document of eq. It is not equivalent to numpy.in1d.

1 Like

A year later, is there now such a function? Or an efficient way of implementing similar behavior?

Thanks for the information Keep suggesting this type of post. looking for the same info.

isin has native support starting in torch 1.10. See: torch.isin — PyTorch master documentation