Robust Classification via a Single Diffusion Model

Huanran Chen, Yinpeng Dong, Zhengyi Wang, Xiao Yang, Chengqi Duan +2 more
5/24/2023
cs.CVcs.CRcs.LG

Official code: huanranchen/DiffusionClassifier (97 stars, last commit 2025-03-07). 1 more implementation below.

Abstract

Diffusion models have been applied to improve adversarial robustness of image classifiers by purifying the adversarial noises or generating realistic data for adversarial training. However, diffusion-based purification can be evaded by stronger adaptive attacks while adversarial training does not perform well under unseen threats, exhibiting inevitable limitations of these methods. To better harness the expressive power of diffusion models, this paper proposes Robust Diffusion Classifier (RDC), a generative classifier that is constructed from a pre-trained diffusion model to be adversarially robust. RDC first maximizes the data likelihood of a given input and then predicts the class probabilities of the optimized input using the conditional likelihood estimated by the diffusion model through Bayes' theorem. To further reduce the computational cost, we propose a new diffusion backbone called multi-head diffusion and develop efficient sampling strategies. As RDC does not require training on particular adversarial attacks, we demonstrate that it is more generalizable to defend against multiple unseen threats. In particular, RDC achieves $75.67\%$ robust accuracy against various $\ell_\infty$ norm-bounded adaptive attacks with $ε_\infty=8/255$ on CIFAR-10, surpassing the previous state-of-the-art adversarial training models by $+4.77\%$. The results highlight the potential of generative classifiers by employing pre-trained diffusion models for adversarial robustness compared with the commonly studied discriminative classifiers. Code is available at \url{https://github.com/huanranchen/DiffusionClassifier}.

View on arXivView PDF

Code Implementations(2)

Official code implement of Robust Classification via a Single Diffusion Model

973C++, CudaNov 17, 20231 years ago
815C++, CudaJan 30, 20232 years ago

Similar Papers

Cite this paper

@article{chen2023robust,
  title  = {Robust Classification via a Single Diffusion Model},
  author = {Huanran Chen and Yinpeng Dong and Zhengyi Wang and Xiao Yang and Chengqi Duan and Hang Su and Jun Zhu},
  year   = {2023},
  eprint = {2305.15241},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2305.15241v2},
  journal = {ICML 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2305.15241.svg)](https://codeofpaper.com/paper/2305.15241)

Discussion