NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Robust Classification via a Single Diffusion Model

Huanran Chen, Yinpeng Dong, Zhengyi Wang, Xiao Yang, Chengqi Duan, Hang Su, Jun Zhu

TL;DR

This paper introduces the Robust Diffusion Classifier (RDC), a method that transforms a pre-trained generative diffusion model into a highly resilient image classifier. By maximizing the likelihood of an input image and using Bayesian inference to predict classes, RDC achieves state-of-the-art adversarial robustness on CIFAR-10 without requiring specific training against attacks, significantly outperforming traditional adversarial training in generalizing to unseen threats.

What Problem Does This Paper Address?

Deep learning models are notoriously "brittle." Small, human-imperceptible perturbations—known as adversarial examples—can easily trick a state-of-the-art classifier into misidentifying an image.

Current defenses generally fall into two camps:

  1. Adversarial Training (AT): Training models on "broken" images. While effective against the specific attacks seen during training, these models often fail against "unseen" types of attacks.
  2. Diffusion-based Purification: Using diffusion models to "clean" an image before handing it to a standard classifier. The problem here is that the downstream classifier remains a "discriminative" model with a fragile decision boundary that adaptive attackers can still exploit.

The authors argue that the root of the problem is the discriminative nature of standard classifiers. They don't truly understand the "shape" of the data distribution (the data manifold). Generative models, specifically diffusion models, capture this structure much better.

Methods

The authors propose the Robust Diffusion Classifier (RDC), which treats classification as a generative task rather than a discriminative one. It consists of two main stages:

Overview of the Robust Diffusion Classifier pipeline, featuring Likelihood Maximization and the Diffusion Classifier.
  1. Likelihood Maximization (LM): Before classifying, the system takes the input image $x$ and performs a few steps of gradient-based optimization to move it toward a region of higher likelihood under the diffusion model. This essentially "nudges" the adversarial image back toward the manifold of real, clean data.
  2. Diffusion Classifier (DC): Once "purified" by LM, the image is classified using Bayes' theorem: $p(y|x) \propto p(x|y)p(y)$. To estimate the conditional likelihood $p(x|y)$, the model calculates the "diffusion loss" (the error in predicting added noise) for every possible class $y$. The class with the lowest noise-prediction error is deemed the most likely.

Technical Innovations

  • Multi-head Diffusion: Standard diffusion models predict noise for one class at a time, which is computationally expensive if you have 10 or 100 classes. The authors modified the UNet backbone to output noise predictions for all classes simultaneously in a single forward pass, reducing time complexity from $\mathcal{O}(K \times T)$ to $\mathcal{O}(T)$.
  • Theoretical Validation: They prove that an optimal diffusion model would achieve 100% robust accuracy under common threat models, providing a strong theoretical foundation for using generative models as classifiers.

Datasets

The researchers evaluated RDC on several standard computer vision benchmarks:

  • CIFAR-10: The primary benchmark for adversarial robustness.
  • CIFAR-100: To test scalability to more classes.
  • Restricted ImageNet: A subset of ImageNet with 9 super-classes to test performance on higher-resolution data.
  • CIFAR-10-C: Used specifically to analyze the model's ability to detect out-of-distribution (O.O.D.) data and common corruptions like blur or fog.

Key Insights and Ideas

  • Generative > Discriminative for Robustness: Discriminative models try to draw a line between classes. In high-dimensional space, it's easy for an attacker to find a "hole" in that line. Generative models model the classes themselves; to fool them, an attacker has to make the image actually look like the other class, which is much harder.
  • The Power of Pre-optimization: Simply using a diffusion classifier isn't enough because practical models aren't perfect. The "Likelihood Maximization" step is crucial because it moves the input to a region where the diffusion model’s density estimation is most accurate.
  • No "Obfuscated Gradients": Many defenses "cheat" by making the model's gradients noisy or flat to break optimization-based attacks. The authors show that RDC has very low gradient variance, meaning its robustness is genuine and not just a result of making the attacker's job confusing.

Key Results

  • SOTA Robustness: On CIFAR-10, RDC achieved 75.67% robust accuracy against $\ell_\infty$ adaptive attacks ($\epsilon=8/255$). This is a +4.77% improvement over the previous state-of-the-art adversarial training method (AT-EDM).
  • Superior Generalization: Against "unseen" threats (attacks the model wasn't specifically designed for), RDC outperformed adversarial training models by over 30%.
  • Efficiency: The multi-head architecture and efficient sampling strategies allowed RDC to achieve high robustness with only 5 optimization steps, making it significantly faster than previous generative defense attempts.

Limitations and Future Work

  • Computational Overhead: Even with the multi-head speedup, RDC requires multiple "Number of Function Evaluations" (NFEs) per image. It is still slower than a simple standard classifier.
  • Scaling to High Resolution: While it works on Restricted ImageNet, running full-scale, high-resolution ImageNet classification with this method remains a challenge due to the memory and compute requirements of diffusion UNets.
  • Model Gap: There is still a gap between the theoretical "optimal" diffusion model (100% robust) and practical ones. The authors suggest that training diffusion models specifically for classification (rather than just generation) could bridge this gap.

Summary updated

BibTeX
@inproceedings{chen2024robust,
  author = {Huanran Chen and Yinpeng Dong and Zhengyi Wang and Xiao Yang and Chengqi Duan and Hang Su and Jun Zhu},
  title = {{Robust Classification via a Single Diffusion Model}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=xaSpuvNYwS},
}
Figure