I have matrices that are 2 x 4 and 3 x 4. I want to find the euclidean distance across rows, and get a 2 x 3 matrix at the end. Here is the code with one for loop that compu
Simply use np.newaxis at the right place:
np.newaxis
np.sqrt((np.square(a[:,np.newaxis]-b).sum(axis=2)))