Diffusion Models Beat GANs on Image Classification

Soumik Mukhopadhyay, Matthew Gwilliam, Vatsal Agarwal, Namitha Padmanabhan, Archana Swaminathan, Srinidhi Hegde, Tianyi Zhou, Abhinav ShrivastavaarXiv 2023 · DOI

Abstract

Diffusion models have recently emerged as the state-of-the-art for generative modeling. This work investigates whether the internal representations learned during the denoising process can be effectively repurposed for discriminative tasks. By extracting and probing intermediate features from a pre-trained U-Net, we demonstrate that diffusion models serve as potent unified representation learners, outperforming previous benchmarks like BigBiGAN on ImageNet classification while maintaining superior generative quality.

Introduction

In computer vision, a long-standing goal is to develop "unified representation learners"—models that can both understand (classify) and create (generate) images within a single framework. Historically, models like BigBiGAN attempted this but often fell short of specialized architectures in both domains. With the rise of Diffusion Models (e.g., DDPM, Stable Diffusion), generative quality has reached new heights. This paper explores a fundamental question: Can the features learned to denoise an image be repurposed to classify it?

Methodology

The authors utilize a pre-trained Guided Diffusion (GD) model based on a U-Net architecture. The approach consists of three primary stages:

  1. Feature Extraction: The U-Net is "probed" by feeding it an image with a specific amount of noise added at timestep $t$. Activations are then extracted from internal blocks ($b$).
  2. Feature Selection & Pooling: Given the high dimensionality of U-Net feature maps, the authors identified optimal configurations through extensive experimentation. For ImageNet, block 24 at noise timestep $t=90$ proved to be the "sweet spot."
  3. Classification Heads: Beyond simple linear probes, the study evaluates Multi-Layer Perceptrons (MLPs), Convolutional Neural Networks (CNNs), and Attention-based blocks to aggregate complex spatial and channel information.
Overview of the feature extraction pipeline and model efficiency across different classification heads.

Key Insights

Discriminative Emergence

Using Centered Kernel Alignment (CKA), the researchers found that later layers of a diffusion U-Net represent images similarly to standard discriminative backbones like ResNet and ViT. This suggests that the denoising objective forces the model to learn high-level semantic structures.

The Timestep and Block Trade-off

Classification performance is highly sensitive to the noise level and the specific block chosen. Features extracted at low noise levels ($t=90$) are significantly better for classification than those at high noise levels ($t=500$). At high noise, the model focuses on global structure, whereas low noise allows it to capture the fine-grained semantic details necessary for accurate labeling.

Impact of noise timestep, U-Net block selection, and pooling size on classification accuracy.

The Power of Attention

While a linear probe on diffusion features yields respectable results, the introduction of an Attention-based classification head significantly boosts performance. On ImageNet, this head increased accuracy from 61.95% to 71.89% without altering the underlying generative model.

Results

The proposed method was evaluated on ImageNet-1k and several Fine-Grained Visual Classification (FGVC) datasets (e.g., CUB-200-2011, Oxford Flowers).

  • ImageNet Performance: Linear probing achieved 61.95% accuracy, surpassing BigBiGAN (60.8%). With an attention head, accuracy reached 71.89%.
  • Generative Quality: The model maintained a Fréchet Inception Distance (FID) of 26.21, outperforming BigBiGAN’s 28.54.
  • Transfer Learning: On specialized datasets like FGVC-Aircraft, diffusion features outperformed SimCLR, demonstrating strong potential for downstream tasks.

Conclusion and Future Work

Diffusion models are currently the strongest candidates for unified representation learning, beating GAN-based approaches in both discriminative and generative metrics. However, challenges remain regarding computational intensity and hyperparameter sensitivity (e.g., optimal block selection varies by dataset). Future research may focus on automated feature selection or regularizing diffusion training to further enhance feature transferability.

Summary updated

BibTeX
@misc{mukhopadhyay2023diffusion,
  author = {Soumik Mukhopadhyay and Matthew Gwilliam and Vatsal Agarwal and Namitha Padmanabhan and Archana Swaminathan and Srinidhi Hegde and Tianyi Zhou and Abhinav Shrivastava},
  title = {{Diffusion Models Beat GANs on Image Classification}},
  year = {2023},
  eprint = {2307.08702},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.08702},
}
Figure