Abstract
The tremendous success of generative models in recent years raises the question whether they can also be used to perform classification. Generative models have been used as adversarially robust classifiers on simple datasets such as MNIST, but this robustness has not been observed on more complex datasets like CIFAR-10. Additionally, on natural image datasets, previous results have suggested a trade-off between the likelihood of the data and classification accuracy. In this work, we investigate score-based generative models as classifiers for natural images. We show that these models not only obtain competitive likelihood values but simultaneously achieve state-of-the-art classification accuracy for generative classifiers on CIFAR-10. Nevertheless, we find that these models are only slightly, if at all, more robust than discriminative baseline models on out-of-distribution tasks based on common image corruptions. Similarly and contrary to prior results, we find that score-based are prone to worst-case distribution shifts in the form of adversarial perturbations. Our work highlights that score-based generative models are closing the gap in classification accuracy compared to standard discriminative models. While they do not yet deliver on the promise of adversarial and out-of-domain robustness, they provide a different approach to classification that warrants further research.
Introduction: Generative vs. Discriminative Classification
In modern machine learning, image classification is dominated by discriminative models. These models learn the decision boundaries between classes, effectively calculating the conditional probability $p(y|x)$. While highly effective, discriminative models do not necessarily capture the underlying distribution of the data; they simply identify features that distinguish one class from another.
An alternative approach is the generative classifier, which learns the distribution of each class, $p(x|y)$. Classification is then performed by determining which class is most likely to have generated a given image. Historically, generative classifiers have struggled with two main issues: the accuracy-likelihood trade-off, where optimizing for image generation quality (likelihood) often degraded classification accuracy, and a lack of scalability to complex natural image datasets like CIFAR-10.
Methodology: Score-Based Likelihood Estimation
The authors propose SBGC (Score-Based Generative Classifier), leveraging the framework of score-based generative models (diffusion models). By modifying the score function—the component that denoises images—to be conditioned on a class label $y$ ($s_\theta(x, t, y)$), the model can learn class-specific distributions.
To perform classification, the model must compute the exact likelihood $\log p(x|y)$ for every possible class. This is achieved by treating the diffusion process as a deterministic Ordinary Differential Equation (ODE). Using a "change of variables" formula, the model can calculate the exact log-likelihood for an image across all classes in CIFAR-10, selecting the class with the highest value as the prediction.
Experimental Results
SBGC demonstrates that generative models can indeed compete with discriminative architectures on complex datasets. On CIFAR-10, SBGC achieved a state-of-the-art accuracy of 95.04% for generative models, significantly outperforming previous approaches such as GLOW and Energy-based models.
Beyond accuracy, the model maintains high generative quality, achieving a negative log-likelihood (NLL) of 3.11 bits/dim, which is competitive with the best generative models on this benchmark.
Analysis: Breaking the Accuracy-Likelihood Trade-off
A significant finding of this research is that the perceived trade-off between classification accuracy and data likelihood is not an inherent property of generative modeling. Previous research suggested that as models became better at generating data (higher likelihood), their classification performance would suffer. SBGC breaks this trend, occupying the top-right quadrant of the accuracy-likelihood spectrum.
Additionally, the model exhibits "convex interpolation." In many generative models, a mixture of two images can mistakenly be assigned a higher likelihood than the original images. SBGC correctly identifies that these "blurry mixtures" are less likely than pure class samples, resulting in a convex likelihood curve during interpolation.
Robustness and Limitations
Despite the hope that "understanding" the data distribution would lead to inherent robustness, the results provide a reality check. While SBGC showed slight improvements over discriminative baselines on certain common corruptions (CIFAR-10-C), it remains highly vulnerable to adversarial attacks. Under a standard PGD (Projected Gradient Descent) attack, the model's accuracy dropped to 0%.
Furthermore, the computational cost of classification is high. Because the model must solve an ODE for every class to determine likelihood, inference is significantly slower than standard discriminative models. For example, an adversarial evaluation of just 216 samples required approximately 90 minutes on an NVIDIA Tesla V100 GPU.
Conclusion
SBGC represents a major step forward for generative classification, proving that these models can achieve high accuracy on natural images without sacrificing generative quality. While the promise of superior adversarial and out-of-distribution robustness remains unfulfilled, the ability of score-based models to close the performance gap with discriminative models suggests that generative classification is a promising avenue for future research, particularly if more perceptually aligned distance metrics can be integrated.
Summary updated