On the Pros and Cons of Momentum Encoder in Self-Supervised Visual Representation Learning

Trung X. Pham, Chaoning Zhang, Axi Niu, Kang Zhang, Chang D. YooOpenReview 2022 · DOI

TL;DR

This paper investigates the role of momentum (Exponential Moving Average - EMA) in self-supervised learning (SSL) for visual representation learning. The authors find that EMA's primary benefit stems from stabilizing training, particularly in the later layers of the encoder. They propose a "projector-only momentum" approach that achieves comparable performance to full EMA while significantly reducing computational overhead.

What Problem Does This Paper Address?

Modern self-supervised learning (SSL) methods, like MoCo, BYOL, and DINO, heavily rely on a "momentum encoder" (using Exponential Moving Average - EMA) to update a teacher network. This EMA mechanism is believed to enhance performance by generating more stable and robust representations. However, the exact reasons behind EMA's effectiveness and its impact on different parts of the neural network have remained unclear. Furthermore, applying EMA to the entire encoder doubles the computational cost due to an extra forward pass, which can be a significant bottleneck. This paper aims to demystify the benefits of EMA, pinpoint its most impactful components, and propose a more efficient alternative.

Methods

The core of this research involves a systematic analysis of EMA's influence on various parts of the SSL encoder. The authors:

  • Disentangle EMA's effect: They investigate the impact of applying EMA to individual blocks or stages of the encoder, rather than the entire network.
  • Gradient Analysis: They monitor the gradients of the loss with respect to the outputs of different encoder blocks to understand how EMA affects learning stability.
  • Projector-Only Momentum: Based on their findings, they propose a novel approach where EMA is applied only to the projector (a small MLP head after the main encoder backbone), while the backbone weights are shared between the online and target networks. This significantly reduces computation.
  • Empirical Evaluation: They conduct extensive experiments across various SSL frameworks (BYOL, DINO, MoCo v2, ReSSL) and datasets, comparing their proposed method against baselines with and without EMA.

Datasets

The paper uses the following datasets for training and evaluation:

  • CIFAR-10
  • CIFAR-100
  • ImageNet-100
  • ImageNet-1K

Key Insights and Ideas

  • Stability is Key: The primary benefit of EMA in SSL is not necessarily about generating better negative pairs or preventing collapse (as previously thought), but rather about stabilizing the training process.
  • Later Layers Matter Most: EMA's impact is significantly more pronounced in the later stages of the encoder (closer to the output, especially the projector) compared to the earlier layers. This is attributed to higher and more fluctuating gradients in these later layers.
  • Projector-Only Momentum is Sufficient: Applying EMA solely to the projector can achieve performance comparable to, or even better than, applying it to the entire encoder, while drastically reducing computational cost.
  • EMA is Beneficial for Non-Momentum Methods: Even frameworks that traditionally don't use EMA (like SimCLR and SimSiam) can see performance improvements when EMA is introduced.

Key Results

  • Performance Boost: Projector-only momentum consistently achieves competitive or superior top-1 accuracy compared to baselines across various SSL methods and datasets. For instance, in DINO on CIFAR-100, EMA on the projector alone achieved 56.54% accuracy, matching the baseline's 58.12% (with full EMA) and outperforming a projector-only EMA approach without momentum.
  • Computational Efficiency: The proposed projector-only momentum significantly reduces computational overhead. For DINO on ImageNet-1K with a ResNet-50 backbone, it requires half the parameters and forward passes compared to the full EMA baseline, while achieving comparable performance.
  • Stability Demonstrated: Visualizations of filter weights show that EMA prevents the "abnormal points" or sudden fluctuations observed in training without momentum, leading to more stable learning curves and preventing accuracy drops. For example, in BYOL on CIFAR-100, training without momentum showed an accuracy drop around epoch 50, which was successfully prevented with EMA.

Limitations and Future Work

  • Focus on ResNet: The current work primarily analyzes EMA's behavior with ResNet backbones for image classification. The authors suggest that investigating other backbones (like ViTs) and modalities (text, audio, video) would be interesting future work.
  • Computational Bottleneck: The paper highlights that the computational cost of SSL, especially with multiple augmentations and large models, can be a significant burden. Their projector-only momentum approach offers a potential solution for labs with limited hardware resources.
  • Hyperparameter Sensitivity: While their projector-only EMA shows less sensitivity to momentum coefficient changes compared to traditional EMA, further exploration of optimal hyperparameters for different scenarios could be beneficial.

Summary updated

BibTeX
@misc{pham2022pros,
  author = {Trung X. Pham and Chaoning Zhang and Axi Niu and Kang Zhang and Chang D. Yoo},
  title = {{On the Pros and Cons of Momentum Encoder in Self-Supervised Visual Representation Learning}},
  year = {2022},
  eprint = {2208.05744},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2208.05744},
}
Figure