How to make Numpy treat each row/tensor as a value
问题 Many functions like in1d and setdiff1d are designed for 1-d array. One workaround to apply these methods on N-dimensional arrays is to make numpy to treat each row (something more high dimensional) as a value. One approach I found to do so is in this answer Get intersecting rows across two 2D numpy arrays by Joe Kington. The following code is taken from this answer. The task Joe Kington faced was to detect common rows in two arrays A and B while trying to use in1d . import numpy as np A = np