EqCo: Equivalent Rules for Self-supervised Contrastive Learning

Benjin Zhu, Junqiang Huang, Zeming Li, Xiangyu Zhang, Jian Sun

Introduction

In the field of self-supervised learning, contrastive learning has emerged as a dominant paradigm. The core objective is to train a neural network to pull together different augmented views of the same image (positive pairs) while pushing them away from views of other images (negative samples). For years, a prevailing consensus in the research community—reinforced by influential frameworks like MoCo and SimCLR—was that "more is better": performance was thought to scale directly with the number of negative samples ($K$). Consequently, state-of-the-art models often require massive memory banks or giant training batches to maintain thousands of negatives.

EqCo (Equivalent Rules) challenges this myth. By introducing an adaptive scaling rule for the loss margin, researchers have demonstrated that high-quality representations can be learned with as few as 16 negative pairs, effectively eliminating the need for computationally expensive memory architectures.

The EqCo Framework

The authors' approach is rooted in the InfoMax principle, which treats contrastive learning as maximizing the lower bound of mutual information between positive pairs. They identify that the perceived performance gap between small and large negative sample sizes is largely an artifact of using a fixed margin in the InfoNCE loss function.

To address this, they propose the Equivalent Rule for the margin ($m$): $$m = \tau \log\left(\frac{\alpha}{K}\right)$$ Where $\tau$ is the temperature hyperparameter, $K$ is the number of negative samples, and $\alpha$ is a constant representing a target large number of negatives. By adaptively adjusting $m$ as $K$ varies, EqCo ensures that the mutual information bound and gradient magnitudes remain consistent across different sample sizes.

Figure 2: With the EqCo margin rule, the mutual information bound ($f_{bound}$) converges to the same level regardless of the number of negative samples ($K$), allowing small-batch models to mimic the optimization behavior of large-batch counterparts.

To demonstrate the practical utility of this rule, the authors introduced SiMo (Simplified MoCo). SiMo discards the complex memory bank of MoCo v2, relying solely on negatives within the current small batch, while utilizing SyncBN for stability.

Key Results and Insights

The empirical results on ImageNet-1K are striking. In a standard MoCo v2 setup, reducing $K$ from 65,536 to 256 typically results in a 6.1% drop in accuracy. With EqCo, this drop is reduced to a negligible 0.2%. Furthermore, SiMo achieves 68.1% top-1 accuracy on ImageNet using only 16 negative pairs, outperforming the original MoCo v2 which requires over 65,000 negatives.

Beyond raw accuracy, EqCo provides significant theoretical and practical advantages:

  • Gradient Stability: Mathematical analysis shows that EqCo keeps the expectation of the gradient norm bounded and independent of $K$. This prevents the vanishing gradient issues that often plague contrastive learning when using small batches.
  • Avoiding Class Collision: Using fewer negatives can be more semantically "honest." Large $K$ values increase the risk of "class collision," where a negative sample accidentally belongs to the same semantic category as the query, forcing the model to learn incorrect distinctions.
Figure 3: EqCo maintains stable gradient magnitudes ($||dL/dq||$) across varying sizes of negative samples, whereas standard MoCo v2 gradients diminish significantly as the number of negatives decreases.

Conclusion

EqCo proves that the requirement for massive numbers of negative samples in contrastive learning is not a fundamental necessity but a consequence of suboptimal hyperparameter scaling. By calibrating the loss margin, researchers can achieve state-of-the-art performance with drastically reduced computational overhead. While future work remains to explore how these rules apply to non-contrastive frameworks like BYOL or SwAV, EqCo marks a significant step toward making high-performance self-supervised learning accessible without the need for massive hardware resources.

Summary updated

BibTeX
@misc{zhu2020eqco,
  author = {Benjin Zhu and Junqiang Huang and Zeming Li and Xiangyu Zhang and Jian Sun},
  title = {{EqCo: Equivalent Rules for Self-supervised Contrastive Learning}},
  year = {2020},
  eprint = {2010.01929},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.01929},
}
Figure