Papers › Diffusion Models for Adversarial Purification

Diffusion Models for Adversarial Purification

16 May 2022arXiv:2205.07460archive 2025-07-28

Weili Nie, Brandon Guo, Yujia Huang, Chaowei Xiao, Arash Vahdat, Anima Anandkumar

Adversarial purification refers to a class of defense methods that remove adversarial perturbations using a generative model. These methods do not make assumptions on the form of attack and the classification model, and thus can defend pre-existing classifiers against unseen threats. However, their performance currently falls behind adversarial training methods. In this work, we propose DiffPure that uses diffusion models for adversarial purification: Given an adversarial example, we first diffuse it with a small amount of noise following a forward diffusion process, and then recover the clean image through a reverse generative process. To evaluate our method against strong adaptive attacks in an efficient and scalable way, we propose to use the adjoint method to compute full gradients of the reverse generative process. Extensive experiments on three image datasets including CIFAR-10, ImageNet and CelebA-HQ with three classifier architectures including ResNet, WideResNet and ViT demonstrate that our method achieves the state-of-the-art results, outperforming current adversarial training and adversarial purification methods, often by a large margin. Project page: https://diffpure.github.io.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2205.07460")

Code

Syntology Ran 11 of 23 code samples harvested from 5 repositories linked to this paper; 12 have no recorded run. Of those that ran: 3 ran · honoured contract; 2 ran · our draft was wrong; 2 ran · fixture could not drive it; 4 ran with no contract checked.

By repository: official repository: 2 samples from 1 repository, 2 ran; found in paper text by Syntology: 19 samples from 4 repositories, 8 ran; 2 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

NVlabs/DiffPure officialmentioned on GitHubpytorch report
zshsh98/eps-ad mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

23 samples harvested; 11 ran; 3 honoured the contract we drafted; 12 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

3ran · honoured contract
2ran · our draft was wrong
2ran · fixture could not drive it
4ran
12unverified

Licence: 5 of the 23 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 5 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

betas_for_alpha_bar NVlabs/DiffPure/guided_diffusion/gaussian_diffusion.py official repository ran · honoured contract licence not identified · pointer only · 2ab2316ac6fdd869 · report
get_named_beta_schedule NVlabs/DiffPure/guided_diffusion/gaussian_diffusion.py official repository ran · honoured contract licence not identified · pointer only · a086d6286a40b889 · report
EBM point0bar1/ebm-defense/nets.py found in paper text by Syntology ran · metamorphic tier: invariant licence not identified · pointer only · 53b522e213c74c83 · report
downsample chail/gan-ensembling/networks/classifiers/attribute_utils.py found in paper text by Syntology ran · fixture could not drive it fingerprinted MIT (permissive) · a56784666af5bd6d · report
format_time chail/gan-ensembling/networks/classifiers/cifar10_utils.py found in paper text by Syntology ran · our draft was wrong fingerprinted MIT (permissive) · 8d7ec010c29e813b · report
get_keys eladrich/pixel2style2pixel/models/psp.py found in paper text by Syntology ran · our draft was wrong MIT (permissive) · 29b9a890f149a3a6 · report
get_logit chail/gan-ensembling/networks/classifiers/attribute_utils.py found in paper text by Syntology ran · fixture could not drive it MIT (permissive) · a59556109795f95c · report
get_mean_and_std chail/gan-ensembling/networks/classifiers/cifar10_utils.py found in paper text by Syntology ran · metamorphic tier: well formed MIT (permissive) · 3cbdd3b190b16350 · report
lerp_clip chail/gan-ensembling/networks/classifiers/attribute_classifier.py found in paper text by Syntology ran MIT (permissive) · 195d635db8eb778b · report
max_res_from_state_dict chail/gan-ensembling/networks/classifiers/attribute_classifier.py found in paper text by Syntology ran MIT (permissive) · d5eb57879ef1704e · report
Model ermongroup/SDEdit/models/diffusion.py found in paper text by Syntology unverified MIT (permissive) · 3b923ff790cbbc0b · report
define_classifier chail/gan-ensembling/networks/domain_classifier.py found in paper text by Syntology unverified MIT (permissive) · 41e902f9c7c2e2eb · report
define_generator chail/gan-ensembling/networks/domain_generator.py found in paper text by Syntology unverified MIT (permissive) · 773b8b462df07b05 · report
get_softmaxed chail/gan-ensembling/networks/classifiers/attribute_utils.py found in paper text by Syntology unverified MIT (permissive) · 839a62fe894a78a3 · report
is_legal chail/gan-ensembling/utils/LBFGS.py found in paper text by Syntology unverified MIT (permissive) · 45be190c3dfd3c8f · report
modify_layers chail/gan-ensembling/utils/customnet.py found in paper text by Syntology unverified MIT (permissive) · 8659b4900a4273d0 · report
polyinterp chail/gan-ensembling/utils/LBFGS.py found in paper text by Syntology unverified MIT (permissive) · a55a9c6d78060f5a · report
postprocess chail/gan-ensembling/networks/domain_classifier.py found in paper text by Syntology unverified MIT (permissive) · 6774ed80906f2f42 · report
run_on_batch eladrich/pixel2style2pixel/predict.py found in paper text by Syntology unverified MIT (permissive) · a7def332eb991665 · report
state_dict_from_tf_parameters chail/gan-ensembling/networks/classifiers/attribute_classifier.py found in paper text by Syntology unverified MIT (permissive) · 1835534046b4b465 · report
stylegan_setting chail/gan-ensembling/networks/stylegan2/stylegan2_networks.py found in paper text by Syntology unverified MIT (permissive) · 2f887a37af9d3f65 · report
betas_for_alpha_bar identical code first harvested elsewhere ran · honoured contract licence of this copy not recorded · 809d6a4eb92a37c4 · report
get_named_beta_schedule identical code first harvested elsewhere unverified licence of this copy not recorded · 3dfd61c7077a1607 · report

Tasks

Adversarial Purification

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

1x1 ConvolutionAverage PoolingBatch NormalizationBottleneck Residual BlockConvolutionDiffusionDropoutGlobal Average PoolingKaiming InitializationMax PoolingReLUResidual BlockResidual ConnectionWide Residual BlockWideResNet

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections