adambielski / siamese-triplet

Siamese and triplet networks with online pair/triplet mining in PyTorch
BSD 3-Clause "New" or "Revised" License
3.11k stars 633 forks source link

About generating all possible triplets using combinations() function #73

Open sandipan211 opened 2 years ago

sandipan211 commented 2 years ago

Hi, I am using your code to generate all possible triplet pairs. I see you are using combinations() functions to generate anchor positive pairs. Shouldn't you generate these pairs using permutations()? Example : if I have two labels - label A having embeddings at indices 0, 2 and label B having embeddings at indices 1, 3.

Using your code I am getting <anchor, positive, negative> triplets as: <0,2,1>, <0,2,3>, <1,3,0>, <1,3,2>.

However, using this I am not getting triplets <2,0,1>, <2,0,3>...., etc. using combinations() as written in your code. These will be different from <0,2,1> and <0,2,3> right?

Kindly help me out in understanding why you used combinations() function and claiming that you have got all anchor-positive pairs? If you have read about this from a paper, kindly cite it for me. It's quite urgent. Looking forward to your reply. Thank you.

adambielski commented 2 years ago

@sandipan211 I think you are correct, combinations is not generating all possible triplets, so that's a bug that I missed. Looks like using permutations fixes it. Good catch!