Improving Deep Binary Embedding Networks by Order-aware Reweighting of Triplets

Jikai Chen, Hanjiang Lai, Libing Geng, Yan Pan

TL;DR

This paper introduces an order-aware reweighting strategy for training deep hashing networks. By weighting triplets based on how much their misranking affects Mean Average Precision (MAP) and using a squared triplet loss, the authors significantly boost image retrieval performance across several benchmark datasets.

What Problem Does This Paper Address?

Image retrieval at scale requires converting images into compact binary codes (hashing) for lightning-fast searching. The gold standard for training these networks is the triplet loss, which encourages a "query" image to be closer to a "positive" match than to a "negative" one.

However, standard triplet loss has a major blind spot: it treats all triplets equally or selects "hard" ones based purely on the raw loss value. In real-world retrieval, the order of the results matters immensely—a mistake at the top of the search results is far more damaging than one at the bottom. Existing methods often ignore these ranking relations, leading to sub-optimal models that waste effort on uninformative triplets.

Methods

The authors propose a two-pronged approach to make the triplet loss "order-aware":

  1. Order-aware Weighting Factor ($\lambda$): Instead of treating every triplet the same, they calculate a weight based on the Mean Average Precision (MAP). For a given triplet in a mini-batch, they calculate the MAP of the current rank list. Then, they swap the positions of the positive and negative images and calculate the MAP again. The difference between these two MAP values becomes the triplet's weight. This ensures that triplets that significantly impact the retrieval quality get the most attention during training.

    Figure 2: Motivation of our method. Given a query code hi in a mini-batch, we return a rank list π for hi. The white bars represent codes that are irrelevant to the query, and black bars represent the relevant codes. The arrows denote the weights and the moving di- rections of the items. Two example triplets, ℓ(hi, hπ3, hπ1) = 1 and ℓ(hi, hπr−1, hπr−2) = 4, are misranked by the current hashing model. Left: the weights of the triplets (see the arrows on the left) based on the loss. However, the hπ3, hπ1 are in the top positions and top results are more important in retrieval task. To better quan- tify the misranked triplet, we adopt the change of MAP by swapping the positions of the positive and negative codes to weight these mis- ranked triplets. Right: the better choice to reweight the two triplets (see the arrows on the right).
  2. Squared Triplet Ranking Loss: The authors replace the traditional linear triplet loss with a squared version. Mathematically, this causes "hard" triplets (those with higher loss) to dominate the gradient, while "easy," well-classified triplets contribute negligible signal. This prevents the model from being overwhelmed by the sheer number of easy triplets typically found in large datasets.

The overall architecture (seen in Figure 1) uses a deep CNN (GoogLeNet) to extract features, followed by a fully connected layer and a sigmoid activation to produce the final binary-like codes.

Overview of the triplet-based hashing network architecture.

Datasets

The method was evaluated on four diverse benchmark datasets:

  • VOC2007: General consumer photographs with 20 object classes.
  • Stanford Dogs: Fine-grained categorization featuring 120 dog breeds.
  • SUN397: A large-scale scene recognition dataset with 397 categories.
  • CUB-200-2011: A challenging fine-grained dataset of 200 bird species.

Key Insights and Ideas

  • Loss is not Importance: A high loss value doesn't always mean a triplet is important for retrieval. A triplet might have a high loss but be located at the very end of a rank list where it doesn't affect the user experience. By using MAP-based weighting, the model focuses on the "top-of-list" errors that actually matter.
  • The Power of Squaring: Moving from a linear to a quadratic loss function is a simple but powerful way to perform implicit hard-negative mining. It ensures that the informative, difficult triplets comprise the majority of the total loss and dominate the backpropagation process.
  • Ranking over Classification: The paper reinforces the idea that hashing is fundamentally a ranking problem, not just a classification problem, and training objectives should reflect that.

Key Results

The proposed method consistently outperformed state-of-the-art baselines (like TripletH and DSH) across all bit lengths (16, 32, 48, 64 bits).

  • VOC2007: Achieved a MAP of 0.8227 (64 bits), a significant jump over TripletH's 0.7897.
  • CUB-200-2011: Showed the most dramatic improvement, rising from 0.6312 (TripletH) to 0.6949 (Ours) at 64 bits.
  • Ablation Studies: Confirmed that both the order-aware weights and the squared loss contribute to the performance gain. Interestingly, testing different powers ($\gamma$) for the loss showed that $\gamma=2$ or $3$ provided the best results.
Comparison of MAP across different datasets and loss power values.

Limitations and Future Work

  • Computational Complexity: Calculating MAP for every triplet in a mini-batch adds overhead. While the authors mitigate this by only calculating it within mini-batches, scaling this to extremely large batch sizes might require more efficient approximation methods.
  • Hyperparameter Sensitivity: While $\gamma=2$ worked well here, the optimal weighting and loss power might vary depending on the specific characteristics of new datasets or different retrieval metrics (like Precision@K).

In summary, this work provides a elegant way to align the training objective of deep hashing networks with the actual goals of image retrieval: getting the top results right.

Summary updated

Abstract

In this paper, we focus on triplet-based deep binary embedding networks for image retrieval task. The triplet loss has been shown to be most effective for the ranking problem. However, most of the previous works treat the triplets equally or select the hard triplets based on the loss. Such strategies do not consider the order relations, which is important for retrieval task. To this end, we propose an order-aware reweighting method to effectively train the triplet-based deep networks, which up-weights the important triplets and down-weights the uninformative triplets. First, we present the order-aware weighting factors to indicate the importance of the triplets, which depend on the rank order of binary codes. Then, we reshape the triplet loss to the squared triplet loss such that the loss function will put more weights on the important triplets. Extensive evaluations on four benchmark datasets show that the proposed method achieves significant performance compared with the state-of-the-art baselines.
BibTeX
@article{chen2020improving,
  author = {Jikai Chen and Hanjiang Lai and Libing Geng and Yan Pan},
  title = {{Improving Deep Binary Embedding Networks by Order-aware Reweighting of Triplets}},
  journal = {IEEE Trans. Circuits Syst. Video Technol.},
  year = {2020},
  url = {https://openreview.net/forum?id=MwvhL_QZ-T},
}
Figure