How to find intersecting rows in two tensors?

Viewed 37

I have two unequal length 2d tensors in tensorflow and I have to find the 1d boolean tensor that gives information if rows of the first tensor are present in the second. For example: if tensor1 = [[0,1,1], [0,1,0], [0,1,2]] and tensor2 = [[0,0,0],[0,0,1],[0,1,1],[1,1,1]], then the 1d tensor should be [True, False, False].

I have tried this with tf.equal() function using broadcasting but it takes up a lot of memory. I want this function to be time and memory-optimized because the tensors are very large. Could somebody recommend any suggestions on how to implement this?

0 Answers
Related