Maintaining Difficulty: A Margin Scheduler for Triplet Loss in Siamese Networks Training

arXiv cs.LG / 3/30/2026

💬 OpinionIdeas & Deep AnalysisModels & Research

Key Points

  • Triplet Margin Ranking Loss in Siamese Networks uses a margin parameter μ to enforce separation between positive and negative pairs, but many triplets can effectively exceed μ during training.
  • The authors argue that keeping μ fixed may cap the learning process because the difficulty of triplets changes over time as more violating (or non-violating) examples are observed.
  • They introduce a margin scheduler that updates μ each epoch based on the fraction of “easy” triplets, aiming to maintain a consistent training difficulty level.
  • Experiments across four datasets show that the scheduler improves verification performance versus both a constant-margin baseline and a monotonically increasing margin approach.

Abstract

The Triplet Margin Ranking Loss is one of the most widely used loss functions in Siamese Networks for solving Distance Metric Learning (DML) problems. This loss function depends on a margin parameter {\mu}, which defines the minimum distance that should separate positive and negative pairs during training. In this work, we show that, during training, the effective margin of many triplets often exceeds the predefined value of {\mu}, provided that a sufficient number of triplets violating this margin is observed. This behavior indicates that fixing the margin throughout training may limit the learning process. Based on this observation, we propose a margin scheduler that adjusts the value of {\mu} according to the proportion of easy triplets observed at each epoch, with the goal of maintaining training difficulty over time. We show that the proposed strategy leads to improved performance when compared to both a constant margin and a monotonically increasing margin scheme. Experimental results on four different datasets show consistent gains in verification performance.