omoindrot / tensorflow-triplet-loss

Implementation of triplet loss in TensorFlow
https://omoindrot.github.io/triplet-loss
MIT License
1.12k stars 283 forks source link

misleading pairwise distances implementation. #12

Closed lc82111 closed 6 years ago

lc82111 commented 6 years ago

I think below line is some misleading. https://github.com/omoindrot/tensorflow-triplet-loss/blob/master/model/triplet_loss.py#L29 Instead of distances = tf.expand_dims(square_norm, 0) - 2.0 * dot_product + tf.expand_dims(square_norm, 1) , I prefer distances = tf.expand_dims(square_norm, 1) - 2.0 * dot_product + tf.expand_dims(square_norm, 0) , which is more consisten with ||a - b||^2 = ||a||^2 - 2 <a, b> + ||b||^2.

omoindrot commented 6 years ago

Done :)

lc82111 commented 6 years ago

Well done :)