Abstract
We investigate the role of projection heads, also known as projectors, within the encoder-projector framework (e.g., SimCLR) used in contrastive learning. We aim to demystify the observed phenomenon where representations learned before projectors outperform those learned after -- measured using the downstream linear classification accuracy, even when the projectors themselves are linear. In this paper, we make two significant contributions towards this aim. Firstly, through empirical and theoretical analysis, we identify two crucial effects -- expansion and shrinkage -- induced by the contrastive loss on the projectors. In essence, contrastive loss either expands or shrinks the signal direction in the representations learned by an encoder, depending on factors such as the augmentation strength, the temperature used in contrastive loss, etc. Secondly, drawing inspiration from the expansion and shrinkage phenomenon, we propose a family of linear transformations to accurately model the projector's behavior. This enables us to precisely characterize the downstream linear classification accuracy in the high-dimensional asymptotic limit. Our findings reveal that linear projectors operating in the shrinkage (or expansion) regime hinder (or improve) the downstream classification accuracy. This provides the first theoretical explanation as to why (linear) projectors impact the downstream performance of learned representations. Our theoretical findings are further corroborated by extensive experiments on both synthetic data and real image data.
Introduction: The Generalization Puzzle
In the landscape of Self-Supervised Learning (SSL), contrastive learning methods like SimCLR and CLIP have established a peculiar "best practice": training an encoder $f$ followed by a small neural network called a "projection head" $g$. Once training is complete, the projector is typically discarded, and only the encoder's features $h$ are used for downstream tasks.
The mystery lies in the fact that even when $g$ is a simple linear layer, the features $h$ (pre-projector) almost always yield better linear classification accuracy than the embeddings $z$ (post-projector). Theoretically, a linear transformation should not "lose" information that a subsequent linear classifier could not recover. This paper provides a theoretical foundation to explain this phenomenon through the lens of high-dimensional asymptotics and inductive bias.
Methodology
The researchers decouple the training process by focusing on a frozen, well-trained encoder. They model the encoder's output using a 2-component Gaussian Mixture Model (GMM), representing different classes. Key analytical tools include:
- Spectral Decomposition: Analyzing the singular values and vectors of the projector matrix $W$.
- High-Dimensional Asymptotics: Utilizing the Convex Gaussian Minimax Theorem (CGMT) to characterize downstream classification error as sample size $n$ and dimensionality $p$ both approach infinity.
- Loss Approximation: Simplifying the SimCLR loss into a univariate function of an "expansion measure" to find explicit solutions for the optimal projector.
Expansion and Shrinkage
The central finding is that the contrastive loss induces two competing geometric effects on the projection head: expansion and shrinkage of signal directions.
The projector does not treat all directions equally. Its behavior is primarily governed by the temperature ($\tau$) hyperparameter and augmentation strength. High temperatures generally lead to expansion, where the projector "highlights" the signal direction. Conversely, low temperatures lead to shrinkage, where the projector "hides" the signal to satisfy the uniformity requirement of the contrastive loss.
Key Results
- Inductive Bias as a Norm Change: In high-dimensional settings, classifiers like Logistic Regression converge to a "max-margin" solution. Applying a linear projector $W$ is equivalent to changing the geometry (the norm) in which that margin is calculated. This change in inductive bias is what impacts generalization.
- Monotonicity of Error: Downstream test error is a monotonic function of expansion strength. In the expansion regime, embeddings $z$ can actually outperform features $h$. In the shrinkage regime, they perform worse.
- Phase Transition: The authors derived a mathematical formula for the transition boundary $\tau^*$. Experiments on STL-10 and synthetic data closely match this theoretical curve, showing that the "puzzling effect" of projectors is specifically a high-dimensional phenomenon where inductive bias dominates.
Conclusion
By framing the projector as a "reparameterizer of inductive bias" rather than a simple feature extractor, this work provides a rigorous explanation for standard SSL practices. It suggests that while discarding projectors is often beneficial due to the common use of low temperatures (shrinkage regime), carefully tuned hyperparameters could potentially allow projectors to enhance downstream performance. Future work remains to extend this theory to joint encoder-projector training and more complex, non-linear architectures.
Summary updated