def prepare_input(d,q): f = np.zeros(d.shape[:2]).astype('int32') for i in range(d.shape[0]): f[i,:] = np.in1d(d[i,:,0],q[i,:,0]) return f