Learning Rich Nearest Neighbor Representations from Self-supervised Ensembles

Bram Wallace, Devansh Arpit, Huan Wang, Caiming Xiong

TL;DR

This paper introduces an unsupervised ensembling framework that combines multiple self-supervised vision models by learning a unified representation directly through gradient descent. Instead of relying on naive feature concatenation or averaging, it optimizes sample representations to ensure each individual model’s features can be recovered via small MLPs—both during training and at inference time. The resulting features yield consistent performance gains in nearest-neighbor evaluation across multiple vision benchmarks, even when applied to a single self-supervised model.

What Problem Does This Paper Address?

While model ensembling is standard practice in supervised learning (e.g., averaging class probability outputs), combining independently trained self-supervised learning (SSL) models remains an open challenge. Contrastive and self-supervised models learn unaligned latent coordinate spaces, meaning simple operations like feature concatenation can balloon dimensionality, while feature averaging can lose unique task-specific geometric properties.

Furthermore, existing distillation approaches typically require training a whole new student backbone from scratch. The authors ask: How can we optimally combine representations from frozen, diverse self-supervised models without needing labels, heavy retraining, or data augmentation?

Methods

The authors reframe ensembling through an information recoverability principle: a good ensemble representation should contain sufficient information to reconstruct the features extracted by all individual models.

       Learned Representation (ψ)
             /     |     \
       [MLP 1]  [MLP 2]  [MLP m]
          ↓        ↓        ↓
Reconstructed features match ground truth:
        z^(1)    z^(2)    z^(m)
  1. Feature Extraction: Intermediate representations are extracted from $M$ frozen convolutional backbones (e.g., ResNet-50s) and $L_2$-normalized. Because no augmentations are used, these features are cached upfront.
  2. Memory Bank Representation: Each training sample $x_i$ is assigned a learnable latent vector $\psi_i$, initialized to the normalized average across all $M$ models' features.
  3. Reconstruction MLPs: For each backbone $j$, a small 2-layer MLP $\phi_j$ maps the latent vector $\psi_i$ back toward that model's feature $z_i^{(j)}$.
  4. Joint Training: Both the MLPs and latent vectors $\Psi$ are jointly updated via SGD using a cosine similarity loss.
  5. Inference via Test-Time Optimization: When evaluating unseen images, the MLPs $\Phi$ are frozen. A test representation $\psi'$ is initialized as the average feature of the ensemble and directly optimized via gradient descent to maximize cosine similarity with the outputs of all frozen feature extractors.

Datasets

  • Pretraining / Source Dataset: ImageNet (ILSVRC 2012).
  • Transfer Evaluation Datasets: CIFAR-10, CIFAR-100, Street View House Numbers (SVHN), Food101, and EuroSat (all standard splits via the VISSL library).
  • No new benchmarks were created; all evaluations use existing public datasets.

Key Insights and Ideas

  • Test-Time Optimization for Representations: Rather than training a static projection network or student backbone, representations are optimized on-the-fly at inference time using backpropagation.
  • Unexpected Single-Model Gains: Applying this method to a single model (mapping $\psi \to z^{(1)}$) still yields non-trivial improvements (e.g., +1.8% on ImageNet for Barlow Twins), mirroring the benefits of self-distillation without extra images or training epochs on the CNN.
  • Deep MLPs as Implicit Regularizers: The authors show that deeper MLPs (up to 6 layers) improve representation quality. Consistent with deep matrix factorization theory, stochastic optimization through deeper networks tends to learn lower-rank, regularized solutions rather than a trivial identity mapping.
  • Feature Space Regularization: Singular value decomposition shows that the learned representations exhibit a less heavy-tailed singular value distribution and tighter cluster structures, indicating that the features spread more uniformly throughout the space while emphasizing semantic clusters.
  • Cross-Dataset MLP Transfer: MLPs trained on ImageNet can be frozen and transferred to novel datasets (like CIFAR or SVHN) to guide test-time optimization of $\psi'$, achieving strong transfer gains without retraining the MLPs.

Key Results

  • ImageNet Ensembling: An ensemble of 4 SimCLR models improved ImageNet $k$-nearest neighbor ($k$-NN) accuracy by over 2%, surpassing 58% top-1 accuracy.
  • Transfer Ensembling: On a varied ensemble consisting of 5 distinct SSL objectives (Barlow Twins, PIRL, RotNet, SwAV, SimCLR), the method outperformed the strongest individual baseline (Barlow Twins) across all 5 transfer datasets. Notably, it achieved an 8.2% boost on SVHN, successfully borrowing the geometric pretext strengths of the otherwise weaker RotNet.
  • Single-Model Improvement: When applied to individual ImageNet models, the approach improved $k$-NN accuracy by 1.8% for Barlow Twins, 1.3% for SimCLR, and 0.4% for a supervised ResNet-50.

Limitations and Future Work

  • Linear Probe Degradation: While the method consistently excels under parameter-free $k$-NN evaluation, the authors observe that under cross-validated $L_2$-regularized linear regression probes, standard feature averaging sometimes matches or outperforms their representations.
  • Inference Latency: Because inference requires iterative gradient descent steps per sample (e.g., 20–50 optimization iterations), test-time latency is considerably higher than a standard feedforward pass.
  • Varying Architectures: Experiments focused primarily on ResNet-50 backbones; testing combinations of radically different architectures (e.g., ConvNets combined with Vision Transformers) remains open for exploration.

Summary updated

BibTeX
@inproceedings{wallace2022learning,
  author = {Bram Wallace and Devansh Arpit and Huan Wang and Caiming Xiong},
  title = {{Learning Rich Nearest Neighbor Representations from Self-supervised Ensembles}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=mKsMcL8FfsV},
}
Figure