sorenbouma / keras-oneshot

koch et al, Siamese Networks for one-shot learning, (mostly) reimplimented in keras
MIT License
373 stars 174 forks source link

computation of L2_distances #15

Open Bear-kai opened 6 years ago

Bear-kai commented 6 years ago

I think the L2_distances in the function _nearest_neighbourcorrect should be computed as follows: dis = pairs[0][i] - pairs[1][i] dis = dis.reshape(dis.size) L2_distances[i] = np.sqrt(dis.dot(dis)) instead of L2_distances[i] = np.sum(np.sqrt(pairs[0][i]**2 - pairs[1][i]**2))

jinwu07 commented 6 years ago

Or simply: L2_distances[i] = np.linalg.norm((pairs[0][i]- pairs[1][i]).reshape(-1), ord=2) The original code isn't quite right.