arXiv(opens in a new tab)cs.CVNov 2019Cited by 20 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:1911.05722

Momentum Contrast for Unsupervised Visual Representation Learning

Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, Ross Girshick

Abstract

We present Momentum Contrast (MoCo) for unsupervised visual representation learning. From a perspective on contrastive learning [29] as dictionary look-up, we build a dynamic dictionary with a queue and a moving-averaged encoder. This enables building a large and consistent dictionary on-the-fly that facilitates contrastive unsupervised learning. MoCo provides competitive results under the common linear protocol on ImageNet classification. More importantly, the representations learned by MoCo transfer well to downstream tasks. MoCo can outperform its supervised pre-training counterpart in 7 detection/segmentation tasks on PASCAL VOC, COCO, and other datasets, sometimes surpassing it by large margins. This suggests that the gap between unsupervised and supervised representation learning has been largely closed in many vision tasks.

1. Introduction

Unsupervised representation learning is highly successful in natural language processing, e.g., as shown by GPT [50, 51] and BERT [12]. But supervised pre-training is still dominant in computer vision, where unsupervised methods generally lag behind. The reason may stem from differences in their respective signal spaces. Language tasks have discrete signal spaces (words, sub-word units, etc.) for building tokenized dictionaries, on which unsupervised learning can be based. Computer vision, in contrast, further concerns dictionary building [54, 9, 5], as the raw signal is in a continuous, high-dimensional space and is not structured for human communication (e.g., unlike words).

Several recent studies [61, 46, 36, 66, 35, 56, 2] present promising results on unsupervised visual representation learning using approaches related to the contrastive loss [29]. Though driven by various motivations, these methods can be thought of as building dynamic dictionaries. The “keys” (tokens) in the dictionary are sampled from data (e.g., images or patches) and are represented by an encoder network. Unsupervised learning trains encoders to perform dictionary look-up: an encoded “query” should be similar to its matching key and dissimilar to others. Learning is formulated as minimizing a contrastive loss [29].

Figure

Figure 1. Momentum Contrast (MoCo) trains a visual representation encoder by matching an encoded query q to a dictionary of encoded keys using a contrastive loss. The dictionary keys {k0,k1,k2,…}\{k_0, k_1, k_2, \ldots\} are defined on-the-fly by a set of data samples. The dictionary is built as a queue, with the current mini-batch enqueued and the oldest mini-batch dequeued, decoupling it from the mini-batch size. The keys are encoded by a slowly progressing encoder, driven by a momentum update with the query encoder. This method enables a large and consistent dictionary for learning visual representations.

From this perspective, we hypothesize that it is desirable to build dictionaries that are: (i) large and (ii) consistent as they evolve during training. Intuitively, a larger dictionary may better sample the underlying continuous, high-dimensional visual space, while the keys in the dictionary should be represented by the same or similar encoder so that their comparisons to the query are consistent. However, existing methods that use contrastive losses can be limited in one of these two aspects (discussed later in context).

We present Momentum Contrast (MoCo) as a way of building large and consistent dictionaries for unsupervised learning with a contrastive loss (Figure 1). We maintain the dictionary as a queue of data samples: the encoded representations of the current mini-batch are enqueued, and the oldest are dequeued. The queue decouples the dictionary size from the mini-batch size, allowing it to be large. Moreover, as the dictionary keys come from the preceding several mini-batches, a slowly progressing key encoder, implemented as a momentum-based moving average of the query encoder, is proposed to maintain consistency.

MoCo is a mechanism for building dynamic dictionaries for contrastive learning, and can be used with various pretext tasks. In this paper, we follow a simple instance discrimination task [61, 63, 2]: a query matches a key if they are encoded views (e.g., different crops) of the same image. Using this pretext task, MoCo shows competitive results under the common protocol of linear classification in the ImageNet dataset [11].

A main purpose of unsupervised learning is to pre-train representations (i.e., features) that can be transferred to downstream tasks by fine-tuning. We show that in 7 downstream tasks related to detection or segmentation, MoCo unsupervised pre-training can surpass its ImageNet supervised counterpart, in some cases by nontrivial margins. In these experiments, we explore MoCo pre-trained on ImageNet or on a one-billion Instagram image set, demonstrating that MoCo can work well in a more real-world, billion-image scale, and relatively uncurated scenario. These results show that MoCo largely closes the gap between unsupervised and supervised representation learning in many computer vision tasks, and can serve as an alternative to ImageNet supervised pre-training in several applications.

References (65)

  • DensePose: Dense human pose estimation in the wild
  • Learning representations by maximizing mutual information across views (opens arXiv in a new tab)
  • Deep clustering for unsupervised learning of visual features
  • Unsupervised pre-training of image features on non-curated data
  • The devil is in the details: an evaluation of recent feature encoding methods
  • DeepLab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs
  • A Simple Framework for Contrastive Learning of Visual Representations
  • Improved baselines with momentum contrastive learning (opens arXiv in a new tab)
  • The importance of encoding versus training with sparse coding and vector quantization
  • The Cityscapes dataset for semantic urban scene understanding
  • ImageNet: A large-scale hierarchical image database
  • BERT: Pre-training of deep bidirectional transformers for language understanding
  • Unsupervised visual representation learning by context prediction
  • Multi-task self-supervised visual learning
  • Adversarial feature learning
  • Large scale adversarial representation learning (opens arXiv in a new tab)
  • Discriminative unsupervised feature learning with convolutional neural networks
  • The Pascal Visual Object Classes (VOC) Challenge
  • Unsupervised representation learning by predicting image rotations
  • Rich feature hierarchies for accurate object detection and semantic segmentation
  • Detectron, 2018
  • The reversible residual network: Backpropagation without storing activations
  • Generative adversarial nets
  • Accurate, large minibatch SGD: Training ImageNet in 1 hour (opens arXiv in a new tab)
  • Scaling and benchmarking self-supervised visual representation learning
  • LVIS: A dataset for large vocabulary instance segmentation
  • Noise-contrastive estimation: A new estimation principle for unnormalized statistical models
  • Dimensionality reduction by learning an invariant mapping
  • Semantic contours from inverse detectors
  • Rethinking ImageNet pre-training
  • Mask R-CNN
  • Deep residual learning for image recognition
  • Identity mappings in deep residual networks
  • Data-efficient image recognition with contrastive predictive coding (opens arXiv in a new tab)
  • Learning deep representations by mutual information estimation and maximization
  • Batch normalization: Accelerating deep network training by reducing internal covariate shift
  • Re-visiting self-supervised visual representation learning
  • Backpropagation applied to handwritten zip code recognition
  • Fast AutoAugment (opens arXiv in a new tab)
  • Feature pyramid networks for object detection
  • Microsoft COCO: Common objects in context
  • Fully convolutional networks for semantic segmentation
  • Exploring the limits of weakly supervised pretraining
  • Unsupervised learning of visual representations by solving jigsaw puzzles
  • Representation Learning with Contrastive Predictive Coding
  • Learning features by watching objects move
  • Context encoders: Feature learning by inpainting
  • MegDet: A large mini-batch object detector
  • Improving language understanding by generative pre-training
  • Language models are unsupervised multitask learners
  • Faster R-CNN: Towards real-time object detection with region proposal networks
  • Very deep convolutional networks for large-scale image recognition
  • Video Google: a text retrieval approach to object matching in videos
  • YFCC100M: The new data in multimedia research
  • Contrastive multiview coding (opens arXiv in a new tab)
  • The iNaturalist species classification and detection dataset
  • Extracting and composing robust features with denoising autoencoders
  • Unsupervised learning of visual representations using videos
  • Detectron2
  • Unsupervised feature learning via non-parametric instance discrimination (opens arXiv in a new tab)
  • Aggregated residual transformations for deep neural networks
  • Unsupervised embedding learning via invariant and spreading instance feature
  • Colorful image colorization
  • Split-brain autoencoders: Unsupervised learning by cross-channel prediction
  • Local aggregation for unsupervised learning of visual embeddings

Cited by (20)