Abstract
Many leading self-supervised methods for unsupervised representation learning, in particular those for embedding image features, are built on variants of the instance discrimination task, whose optimization is known to be prone to instabilities that can lead to feature collapse. Different techniques have been devised to circumvent this issue, including the use of negative pairs with different contrastive losses, the use of external memory banks, and breaking of symmetry by using separate encoding networks with possibly different structures. Our method, termed BAM, rather than directly matching features of different views (augmentations) of input images, is based on matching their self-attention vectors, which are the distributions of similarities to the entire set of augmented images of a batch. We obtain rich representations and avoid feature collapse by minimizing a loss that matches these distributions to their globally balanced and entropy regularized version, which is obtained through a simple self-optimal-transport computation. We ablate and verify our method through a wide set of experiments that show competitive performance with leading methods on both semi-supervised and transfer-learning benchmarks. Our implementation and pre-trained models are available at github.com/DanielShalam/BAM .
Introduction
Self-supervised learning (SSL) aims to learn useful visual representations without human-annotated labels. The dominant paradigm, instance discrimination, typically treats two augmented views of the same image as a "positive" pair and all other images in a batch as "negatives." While successful, this approach faces two primary challenges: feature collapse, where the model learns trivial solutions mapping all inputs to a single point, and crude labeling, where the rich semantic relationships between different images in a batch are often ignored.
As shown in Figure 1, images from the same class (non-aug) naturally exhibit higher similarity than those from different classes, even when both are treated as negatives in standard contrastive frameworks. BAM leverages these subtle relationships by defining an image's identity through its "social profile"—its similarity to every other image in the batch.
Methodology: Balanced Self-Attention Matching (BAM)
BAM shifts the focus from matching raw feature vectors to matching Self-Attention (SA) distributions. Instead of directly pulling positive pairs together, BAM teaches the model to represent images by how they relate to the entire batch.
The core components of the BAM algorithm include:
- Global Attention: The model computes a similarity matrix for the entire batch. Crucially, "positive" pairs (views of the same image) are masked out, forcing the model to rely on "negative" relationships to define features.
- Attention Balancing via Optimal Transport: To prevent feature collapse, BAM employs the Sinkhorn-Knopp algorithm to compute a "balanced" target distribution. This ensures that every image in the batch is equally "attended to," creating a doubly stochastic matrix that acts as a structural regularizer.
- Entropy Regularization: By maintaining a temperature gap between predictions and targets, the model is encouraged to produce informative, non-collapsed representations.
Experimental Results
BAM was evaluated on ImageNet-1K and various downstream tasks, demonstrating competitive performance and high stability against heavyweights like DINO and MAE.
- ImageNet-1K: Using a ViT-Base architecture, BAM achieved 78.1% top-1 accuracy in linear probing and 83.2% in fine-tuning.
- Downstream Versatility: BAM showed strong results in object detection (COCO), segmentation (ADE20K), and video instance segmentation (DAVIS-2017). Notably, it outperformed DINO on DAVIS-2017, suggesting its attention-based features are superior for temporal tracking.
- Transfer Learning: The method proved robust across diverse datasets, including CIFAR-10/100, Food-101, and Oxford Pets, maintaining a better balance between linear and fine-tuning performance than generative methods like MAE.
Conclusion
BAM introduces a novel perspective on self-supervised learning by treating the relationships between "negative" samples as the primary signal rather than noise. By combining self-attention matching with global balancing via Optimal Transport, BAM provides a stable and effective framework for learning rich visual representations that avoid the pitfalls of feature collapse without requiring complex architectural asymmetries.
Summary updated