Skip to main content
QUICK REVIEW

[Paper Review] Cross-Batch Memory for Embedding Learning

Xun Wang, Haozhi Zhang|arXiv (Cornell University)|Dec 14, 2019
Domain Adaptation and Few-Shot LearningComputer Science12 references14 citations
TL;DR

This paper proposes Cross-Batch Memory (XBM), a memory-augmented mechanism that stores and dynamically updates embeddings from past mini-batches to enable cross-batch mining of hard negative samples in deep metric learning. By exploiting the 'slow drift' phenomenon—where embeddings change gradually over training—XBM allows a simple contrastive loss to achieve state-of-the-art performance, improving R@1 by 12%-22.5% on large-scale image retrieval datasets with only 0.2 GB extra GPU memory.

ABSTRACT

Mining informative negative instances are of central importance to deep metric learning (DML), however this task is intrinsically limited by mini-batch training, where only a mini-batch of instances is accessible at each iteration. In this paper, we identify a "slow drift" phenomena by observing that the embedding features drift exceptionally slow even as the model parameters are updating throughout the training process. This suggests that the features of instances computed at preceding iterations can be used to considerably approximate their features extracted by the current model. We propose a cross-batch memory (XBM) mechanism that memorizes the embeddings of past iterations, allowing the model to collect sufficient hard negative pairs across multiple mini-batches - even over the whole dataset. Our XBM can be directly integrated into a general pair-based DML framework, where the XBM augmented DML can boost performance considerably. In particular, without bells and whistles, a simple contrastive loss with our XBM can have large R@1 improvements of 12%-22.5% on three large-scale image retrieval datasets, surpassing the most sophisticated state-of-the-art methods, by a large margin. Our XBM is conceptually simple, easy to implement - using several lines of codes, and is memory efficient - with a negligible 0.2 GB extra GPU memory. Code is available at: https://github.com/MalongTech/research-xbm.

Motivation & Objective

  • To address the fundamental limitation in pair-based deep metric learning where hard negative mining is constrained by mini-batch size.
  • To investigate whether past embeddings can approximate current embeddings due to slow feature drift during training.
  • To develop a memory mechanism that enables mining informative negative pairs across multiple mini-batches without increasing computational cost.
  • To demonstrate that integrating XBM into simple loss functions like contrastive loss can surpass complex state-of-the-art methods.
  • To provide a memory-efficient, plug-and-play solution compatible with existing pair-based DML frameworks.

Proposed method

  • Propose a cross-batch memory (XBM) module that stores embeddings from recent mini-batches using a simple enqueue-dequeue mechanism.
  • Leverage the 'slow drift' phenomenon: past embeddings remain highly representative of current model features, enabling approximation without re-computation.
  • Integrate XBM into any pair-based DML framework by connecting current anchors to stored past embeddings for loss computation.
  • Update the memory buffer using features computed during forward passes—no additional inference cost—ensuring computational efficiency.
  • Use a fixed-size buffer to maintain only the most recent embeddings, ensuring memory efficiency with only ~0.2 GB extra GPU memory.
  • Apply the XBM-augmented loss during training, where each anchor is compared against both intra-batch and cross-batch negatives from memory.

Experimental results

Research questions

  • RQ1Can past embeddings from earlier training iterations be effectively used to approximate current embeddings due to slow feature drift?
  • RQ2To what extent can cross-batch mining of hard negatives improve performance in pair-based deep metric learning?
  • RQ3Can a simple contrastive loss with XBM surpass complex state-of-the-art methods like MS loss or FastAP?
  • RQ4How does XBM perform across different backbone networks and datasets in image retrieval?
  • RQ5What is the memory and computational cost of maintaining a cross-batch memory in practice?

Key findings

  • XBM improves R@1 by 12% to 22.5% over baseline contrastive loss on three large-scale image retrieval datasets: SOP, In-shop, and VehicleID.
  • With XBM, a simple contrastive loss outperforms state-of-the-art methods such as MS loss [37], FastAP [2], and MIC [26] by a large margin.
  • On the SOP dataset, XBM with ResNet50 achieves 80.6% R@1, surpassing the previous SOTA of 78.2% (MS loss) and 77.2% (MIC).
  • On In-shop, XBM with ResNet50 reaches 91.3% R@1, exceeding the previous best of 90.9% (FastAP).
  • On VehicleID, XBM with ResNet50 achieves 94.7% R@1 (small set), 93.7% (medium), and 93.0% (large), outperforming FastAP and MIC.
  • The XBM mechanism adds only 0.2 GB of extra GPU memory and requires just a few lines of code to integrate into existing DML frameworks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.