What is triplet loss and its main challenge?
hardAnswer
- L(a, p, n) = max(d(a, p) - d(a, n) + margin, 0), where a=anchor, p=positive, n=negative.
- Wants the anchor closer to positives than to negatives by at least the margin.
- Main challenge: 'triplet mining' — most random triplets are easy (already satisfied), so you must actively sample semi-hard / hard triplets to keep training progressing.
- Standard in face recognition (FaceNet).
- Superseded in most tasks by info-NCE / softmax-based losses.
Check yourself — multiple choice
- Uses two examples
- Anchor + positive + negative; hard-triplet mining is the practical challenge; used in face recognition
- Only two negatives
- No margin needed
Triplet: d(a,p) < d(a,n) - margin; hard mining is key.
#losses#contrastive
Practise Deep Learning
214 interview questions in this topic.
Related questions
- Write the basic contrastive loss and when it's used.
- Write info-NCE / NT-Xent and its role in SSL.
- Why compute softmax + cross-entropy jointly via log-sum-exp?
- How should the output head be designed for a regression task with a strictly positive target?
- How is the output head different for multi-label vs multi-class classification?
- What is label smoothing and why does it help?