Contrastive Factor Analysis

Zhibin Duan, Tiansheng Wen, Yifei Wang, Chen Zhu, Bo Chen, Mingyuan Zhou · OpenReview

Abstract

Factor analysis, often regarded as a Bayesian variant of matrix factorization, offers superior capabilities in capturing uncertainty, modeling complex dependencies, and ensuring robustness. As the deep learning era arrives, factor analysis is receiving less and less attention due to their limited expressive ability. On the contrary, contrastive learning has emerged as a potent technique with demonstrated efficacy in unsupervised representational learning. While the two methods are different paradigms, recent theoretical analysis has revealed the mathematical equivalence between contrastive learning and matrix factorization, providing a potential possibility for factor analysis combined with contrastive learning. Motivated by the interconnectedness of contrastive learning, matrix factorization, and factor analysis, this paper introduces a novel Contrastive Factor Analysis framework, aiming to leverage factor analysis's advantageous properties within the realm of contrastive learning. To further leverage the interpretability properties of non-negative factor analysis, which can learn disentangled representations, contrastive factor analysis is extended to a non-negative version. Finally, extensive experimental validation showcases the efficacy of the proposed contrastive (non-negative) factor analysis methodology across multiple key properties, including expressiveness, robustness, interpretability, and accurate uncertainty estimation.

Introduction: Bridging Classical and Modern ML

In the landscape of unsupervised representation learning, two paradigms have historically occupied distinct niches. Classical Factor Analysis (FA) is a statistical cornerstone known for its ability to model dependencies and capture uncertainty through stochastic latent variables. However, it often lacks the "expressiveness" required to handle the high-dimensional complexity of modern datasets like natural images. Conversely, Contrastive Learning (CL) has become the dominant force in self-supervised learning, utilizing deep neural networks to learn powerful features by distinguishing between positive and negative sample pairs. While highly expressive, CL is typically deterministic, offering limited capacity for uncertainty estimation or feature interpretability.

The conceptual evolution from classical Matrix Factorization to modern Contrastive Factor Analysis.

This work identifies a theoretical bridge between these paradigms. Recent research suggests that certain contrastive losses are mathematically equivalent to matrix factorization. Since Factor Analysis is essentially a Bayesian extension of matrix factorization, there exists a unique opportunity to combine the expressiveness of deep learning with the robust statistical properties of FA. We propose Contrastive Factor Analysis (CFA) to fill this gap.

Methodology

The CFA framework reformulates contrastive learning through a Bayesian lens, moving from point estimates to stochastic latent representations.

Generative Modeling of Relations

Unlike classical FA, which models raw data pixels, CFA models the relation matrix between samples. It factorizes this matrix into latent variables $\theta$ using a Gaussian likelihood. This shift allows the model to inherit the benefits of contrastive objectives while maintaining a generative foundation.

Non-Negative Extension (CNFA)

To enhance interpretability, we extend CFA to a non-negative version (CNFA). By employing Gamma-distributed latent variables, the model encourages sparsity and "parts-based" representations, similar to Non-negative Matrix Factorization (NMF). This leads to naturally disentangled features where individual dimensions correspond to distinct semantic concepts.

Variational Inference and Scalability

To ensure scalability, we utilize a variational inference (VI) framework. We employ the reparameterization trick to enable end-to-end training. For the non-negative CNFA, we approximate the Gamma posterior with a Weibull distribution, which is more amenable to gradient-based optimization. The resulting objective is a tractable contrastive loss that is compatible with standard backbones like ResNet.

Graphical models comparing standard Contrastive Learning (CL), the proposed Generative CFA, and the Variational Inference (VI) network.

Experimental Evaluation

We evaluated CFA and CNFA on standard benchmarks including CIFAR-10, CIFAR-100, and ImageNet-100, as well as Out-of-Distribution (OOD) datasets like Stylized ImageNet and ImageNet-C.

  • Performance and Expressiveness: CFA and CNFA consistently outperformed deterministic baselines like SimCLR and NCL. On ImageNet-100, CNFA achieved a fine-tuning accuracy of 80.2%, surpassing NCL's 79.2%.
  • Robustness to Distribution Shift: The stochastic nature of CFA provides a significant advantage in OOD scenarios. On ImageNet-Sketch, CNFA outperformed NCL by 1.7%, demonstrating superior generalization.
  • Uncertainty Estimation: By analyzing the Shannon entropy of the variational posterior, we found a strong correlation between model uncertainty and prediction accuracy. Metrics like PAvPU confirm that the model's confidence is well-calibrated.
  • Disentanglement: Using the SEPIN metric, CNFA showed markedly better disentanglement than standard CL, particularly in its most significant latent dimensions.

Conclusion

Contrastive Factor Analysis demonstrates that the divide between classical statistical modeling and modern deep learning is narrower than previously thought. By treating latent representations as distributions, we gain the ability to quantify uncertainty and learn interpretable features without sacrificing the performance of deep contrastive methods. Future research may explore hierarchical extensions to capture multi-layer data structures or apply the CFA framework to multi-modal domains where uncertainty and interpretability are paramount.

Summary updated

BibTeX
@misc{duan2024contrastive,
  author = {Zhibin Duan and Tiansheng Wen and Yifei Wang and Chen Zhu and Bo Chen and Mingyuan Zhou},
  title = {{Contrastive Factor Analysis}},
  year = {2024},
  eprint = {2407.21740},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.21740},
}
Figure