Adversarial Diffusion Bridge Model for Reliable Adversarial Purification

## Abstract

Abstract Recently Diffusion-based Purification (DiffPure) has been recognized as an effective defense method against adversarial examples. However, we find DiffPure which directly employs the original pre-trained diffusion models for adversarial purification, to be suboptimal. This is due to an inherent trade-off between noise purification performance and data recovery quality. Additionally, the reliability of existing evaluations for DiffPure is questionable, as they rely on weak adaptive attacks. In this work, we propose a novel Adversarial Diffusion Bridge Model, termed ADBM. ADBM directly constructs a reverse bridge from the diffused adversarial data back to its original clean examples, enhancing the purification capabilities of the original diffusion models. Through theoretical analysis and experimental validation across various scenarios, ADBM has proven to be a superior and robust defense mechanism, offering significant promise for practical applications. Code will be made public soon.

## 1 Introduction

An intriguing problem in machine learning models, particularly Deep Neural Networks (DNNs), is the existence of adversarial examples [, ]. These examples introduce imperceptible adversarial perturbations leading to significant errors, which has posed severe threats to practical applications [, ]. Numerous methods have been proposed to defend against adversarial examples. But attackers can still evade most early methods by employing adaptive attacks [, ]. Adversarial Training (AT) methods [, , , ] are recognized as effective defense methods against adaptive attacks. However, AT typically involves re-training the entire DNNs using adversarial examples, which is impractical for real-world applications. Moreover, the effectiveness of AT is often limited to the specific attacks it has been trained against, making it brittle against unseen threats [, ].

Figure: Figure 1: The inference pipeline of AP (a) and the comparison between DiffPure (b) and ADBM (c). DiffPure relies on the diffused adversarial data distribution (Diffused Adv. Dist.) being close enough to the diffused clean data distribution. ADBM directly builds a reverse process from the diffused adversarial data distribution to clean data distribution.
Refer to caption: x1.png

Recently, Adversarial Purification (AP) methods [, ] have gained increasing attention as they offer a potential solution to defend against unseen threats in a plug-and-play manner without retraining the classifiers. These methods utilize the so-called purification module, which exploits techniques such as generative models, as a pre-processing step to restore clean examples from adversarial examples, as illustrated in Figure 1(a). Recently, diffusion models [], one type of generative model renowned for their efficacy, have emerged as potential AP solutions []. Diffusion models learn transformations between complex data distributions and simple distributions like the Gaussian distribution through forward diffusion and reverse prediction processes. In the context of adversarial defense, Diffusion-based Purification (DiffPure) [], which tries to purify the adversarial examples by first adding Gaussian noise through the forward process with a small diffusion timestep and then recovering clean examples (removing the added Gaussian noise together with adversarial noise) through the reverse process, has achieved superior performance among recent AP methods.

However, we find that utilizing DiffPure in the context of AP is suboptimal. The primary reason is that DiffPure directly employs pre-trained diffusion models originally designed for generative tasks, rather than specifically for AP tasks. To delve deeper, the divergence in data distributions between clean and adversarial examples [, ] often leads to noticeable differences in their respective diffused distributions, while DiffPure relies on the assumption that the two diffused distributions are sufficiently close, such that the original reverse process can recover the diffused adversarial data distribution, as depicted in Figure 1(b). The conflict between the assumption and the actual situation compromises the effectiveness of AP. DiffPure attempts to mitigate this conflict by introducing significant noise with a large diffusion timestep. Nevertheless, this solution is impractical; a substantial diffusion timestep can severely corrupt the global structure of the input, resulting in a fundamental trade-off between noise purification efficiency and recovery quality. In addition, we observe that existing evaluations for DiffPure rely on weak adaptive attacks, which may inadvertently give a false sense of security regarding diffusion-based purification.

To address the aforementioned problems, this study performs a systematic investigation. We first establish a reliable adaptive attack evaluation method for diffusion-based purification. With the rigorous evaluation, our preliminary findings suggest that the robustness of DiffPure is overestimated in existing works [, , ]. To improve the robustness of diffusion-based purification, we then propose a novel Adversarial Diffusion Bridge Model, termed ADBM. Unlike original diffusion models relying on the similarity between the diffused distributions of clean and adversarial examples for a balanced trade-off, ADBM constructs a direct reverse process (or “bridge”) from the diffused adversarial data distribution to the distribution of clean examples, as shown in Figure 1(c). The theoretical analysis supports the superiority of ADBM over using original pre-trained diffusion models (DiffPure). In addition, we discuss how to accelerate ADBM for efficient adversarial purification to enhance the practicality of ADBM as a defense mechanism.

Experimental results show that ADBM achieved better adversarial robustness than DiffPure under reliable adaptive attacks. In particular, ADBM achieved a 4.4% robustness gain compared with DiffPure on average on CIFAR-10 [], while the clean accuracies kept comparable. ADBM also demonstrated competitive performances with AT methods for seen adversarial threats and stood out among recent AP methods. Furthermore, ADBM exhibited much better adversarial robustness than AT methods when facing unseen threats. Additionally, the evaluation results against transfer-based and query-based attacks indicate the practicality of ADBM compared with existing methods.

Our main contributions can be summarized as follows:

- •
We propose ADBM, a novel adversarial diffusion bridge model, as an efficient AP method. Additionally, we investigate methods to accelerate the proposed ADBM.
- •
We conduct a theoretical analysis to illustrate the superiority of ADBM.
- •
We develop a simple yet reliable adaptive attack evaluation method for diffusion-based purification methods.
- •
Experiments in various attack settings validate the effectiveness of ADBM, highlighting its reliability and potential as a defense method for practical scenarios when compared with AT.

## 2 Preliminary and Related Work

Diffusion Models. Given a data distribution $q({\mathbf{x}}_{0})$, DDPM [] constructs a discrete-time Markov chain $\{{\mathbf{x}}_{0},\ldots,{\mathbf{x}}_{T}\}$ as the forward process for ${\mathbf{x}}_{0}\sim q({\mathbf{x}}_{0})$. Gaussian noise is gradually added to ${\mathbf{x}}_{0}$ during the forward process following a scaling schedule $\{\beta_{0},\beta_{1},\cdots,\beta_{T}\}$, where $\beta_{0}=0$ and $\beta_{T}\rightarrow 1$, such that ${\mathbf{x}}_{T}$ is near an isotropic Gaussian distribution:

$$ $\displaystyle q({\mathbf{x}}_{t}|{\mathbf{x}}_{t-1}):={\mathcal{N}}({\mathbf{x }}_{t};\sqrt{1-\beta_{t}}{\mathbf{x}}_{t-1},\beta_{t}{\mathbf{I}}).$ (1) $$

Denote $\alpha_{t}:=1-\beta_{t}$ and $\bar{\alpha}_{t}:=\prod_{i=1}^{t}\alpha_{i}$, then

$$ $\displaystyle q({\mathbf{x}}_{t}|{\mathbf{x}}_{0})$ $\displaystyle={\mathcal{N}}({\mathbf{x}}_{t};\sqrt{\bar{\alpha}_{t}}{\mathbf{x }}_{0},(1-\bar{\alpha}_{t}){\mathbf{I}}),\textit{i.e.},{\mathbf{x}}_{t}({ \mathbf{x}}_{0},{\boldsymbol{\epsilon}})=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{ 0}+\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}},{\boldsymbol{\epsilon}} \sim{\mathcal{N}}({\bm{0}},{\mathbf{I}}).$ (2) $$

To generate examples, the reverse distribution $q({\mathbf{x}}_{t-1}|{\mathbf{x}}_{t})$ should be learned by a model. But it is hard to achieve it directly. In practice, DDPM considers the conditional reverse distribution $q({\mathbf{x}}_{t-1}|{\mathbf{x}}_{t},{\mathbf{x}}_{0})$ and uses ${\mathbf{x}}_{\theta}({\mathbf{x}}_{t},t)$ as an estimate of ${\mathbf{x}}_{0}$,
where

$$ ${\mathbf{x}}_{\theta}({\mathbf{x}}_{t},t):=({\mathbf{x}}_{t}-\sqrt{1-\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t},t))/\sqrt{\bar{ \alpha}_{t}}.$ (3) $$

For a given ${\mathbf{x}}_{0}$, the training loss $L_{d}$ of diffusion models is thus defined as

$$ $\displaystyle L_{d}$ $\displaystyle=\mathbb{E}_{{\boldsymbol{\epsilon}},t}\left[\|{\boldsymbol{ \epsilon}}-{\boldsymbol{\epsilon}}_{\theta}(\sqrt{\bar{\alpha}_{t}}{\mathbf{x} }_{0}+\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}},t)\|^{2}\right].$ (4) $$

To accelerate the reverse process of DDPM, which typically involves hundreds of steps, Song et al. [] propose a DDIM sampler based on the intuition that the multiple reverse steps can be performed at a single step via a non-Markov process.
Song et al. [] generalize the discrete-time diffusion model to continuous-time from the Stochastic Differential Equation (SDE) perspective.

Diffusion Models for Adversarial Robustness. Recent studies have demonstrated the efficacy of diffusion models [] in enhancing adversarial robustness in several ways. Some researches leverage much data generated by diffusion models to improve the AT performance [, ], but these AT-based methods do not generalize well under unseen threat models. Chen et al. [] show that a single diffusion model can be transformed into an adversarially robust classifier using Bayes’ rule, but at thousands of times the inference cost. DiffPure [] employs a diffusion model as a plug-and-play pre-processing module to purify adversarial noise. Wang et al. [] improved DiffPure by employing inputs to guide the reverse process of the diffusion model to ensure the purified examples are close to input examples. Zhang et al. [] improved DiffPure by incorporating the reverse SDE with multiple Langevin dynamic runs. Zhang et al. [] maximized the evidence lower bound of the likelihood estimated by diffusion models to increase the likelihood of corrupted images. DiffPure has also shown potential in improving certified robustness within the framework of randomized smoothing [, ]. Nevertheless, the practicality of randomized smoothing is greatly hindered by the time-consuming Monte Carlo sampling []. Different from these works, we present an diffusion-based purification method for empirical robustness in practical scenarios.

## 3 Reliable Evaluation for DiffPure

Before delving into the details of ADBM, it is important to discuss the white-box adaptive attack for diffusion-based purification first. As the original implementation of DiffPure needs dozens of prediction steps in the reverse process, it is challenging to compute the full gradient of the whole purification process due to memory constraints. To evaluate the robustness of diffusion-based purification, several techniques have been proposed. But we found that the adaptive evaluations for DiffPure remained insufficient, as detailed in Sec. A.1. We build on these previous insights [, , ] to develop a straightforward yet effective adaptive attack method against diffusion-based purification. We employ the gradient-based PGD attack [], utilizing the full gradient calculation via gradient-checkpointing and incorporating a substantial number of EOT [] and iteration steps. Especially, we set the PGD iteration steps to 200, with 20 EOT samples for each iteration. We note that the cost of reliable evaluation is high yet worthwhile to avoid a false sense of security on DiffPure, as discussed in Sec. A.2.
Tab. 2 shows the results of DiffPure with a DDPM sampler under different evaluations.(^1^11The DDPM sampler represents one discretization version of the reverse VP-SDE sampler [], which is originally employed in DiffPure. Their differences become negligible at a large timestep, allowing us to use VP-SDE and DDPM interchangeably throughout our work.) Consistent with Nie et al. [], we conducted the adaptive attack three times on a subset of 512 randomly sampled images from the test set of CIFAR-10. The results demonstrate that our attack significantly reduced the reported robustness of DiffPure, lowering it from 71.29% and 51.13% to 45.83% when compared with the originally reported results [] and the recent best practice [], respectively. We found that increasing the number of iterations or EOT steps further did not lead to higher attack success rates.

**Table 1: Accuracies (%) of DiffPure under various evaluation attacks with an $l_{\infty}$ bound of $\epsilon_{\infty}=8/255$ on CIFAR-10. The timestep $T$ of DiffPure was $100$, following the original implementation.**
| Evaluation | Clean Acc | Robust Acc |
| --- | --- | --- |
| Nie et al. [] | $90.07\pm 0.97$ | $71.29\pm 0.55$ |
| Chen et al. [] | $90.97$ | $53.52$ |
| Lee and Kim [] | $90.43\pm 0.60$ | $51.13\pm 0.87$ |
| Ours (EOT=20, steps=200) | $90.49\pm 0.97$ | $45.83\pm 1.27$ |
| Ours (EOT=40, steps=200) | $\textbf{45.64}\pm 1.14$ |  |
| Ours (EOT=20, steps=400) | $46.16\pm 1.33$ |  |

With the reliable evaluation method, we further investigated the influence of reverse steps and forward steps on the robustness of DiffPure. This exploration offers insights into the effectiveness of diffusion-based purification methods.

Reverse steps. DiffPure suffers from a high inference cost, which greatly hinders its practical application. The reverse step directly impacts the inference cost of DiffPure. Following Lee and Kim [], we evaluated both the original DDPM sampler and the DDIM sampler. We present the results in Tab. 2 using different reverse steps and samplers (standard deviation omitted, about 1%). The results show that decreasing the number of reverse steps significantly reduced both clean accuracy and robustness when using DDPM. However, for the DDIM sampler, although clean accuracy slightly decreased with fewer reverse steps, robustness was not significantly affected. This can be attributed to the fact that DDIM does not introduce additional randomness during the reverse process.

Forward steps. We observed a continuous decrease in clean accuracy and a continuous increase in robustness as the number of forward steps increased. Details can be found in Sec. A.3.

## 4 Adversarial Diffusion Bridge Model

ADBM aims to construct a reverse bridge directly from the diffused adversarial data distribution to the clean data distribution. We derive the training objective for ADBM in Sec. 4.1, and explain how to obtain the adversarial noise for training ADBM in Sec. 4.2. The AP inference process using ADBM is described in Sec. 4.3. We finally show that ADBM has good theoretical guarantees for AP.

### 4.1 Training Objective

ADBM is a diffusion model specifically designed for purifying adversarial noise. It adopts a forward process similar to DDPM, with the difference that ADBM assumes the existence of adversarial noise ${\boldsymbol{\epsilon}}_{a}$ at the starting point of the forward process during training. This means that the starting point of the forward process is ${\mathbf{x}}_{0}^{a}={\mathbf{x}}_{0}+{\boldsymbol{\epsilon}}_{a}$ for each ${\mathbf{x}}_{0}$. Thus, according to Eq. 2, the forward process can be represented as ${\mathbf{x}}_{t}^{a}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{
\alpha}_{t}}{\boldsymbol{\epsilon}},{\boldsymbol{\epsilon}}\sim{\mathcal{N}}({
\bm{0}},{\mathbf{I}}),0\leq t\leq T$, where $T$ denotes the actual forward timestep when performing AP. $T$ is typically set to a lower value for AP, e.g., 100 in DiffPure, than that used in generative tasks, e.g., 1,000, to avoid completely corrupting ${\mathbf{x}}_{0}$. We discuss how to obtain ${\boldsymbol{\epsilon}}_{a}$ in Sec. 4.2.

In the reverse process of ADBM, the objective is to learn a Markov chain $\{\hat{{\mathbf{x}}}_{t}\}_{t:T\to 0}$ that can directly transform from the diffused adversarial data distribution (i.e., ${\mathbf{x}}^{a}_{T}$) to the clean data distribution (i.e., ${\mathbf{x}}_{0}$), as shown in Figure 1(c). To achieve this, the starting point and the end point of $\hat{{\mathbf{x}}}_{t}$ should be defined as $\hat{{\mathbf{x}}}_{T}:={\mathbf{x}}^{a}_{T}$ and $\hat{{\mathbf{x}}}_{0}:={\mathbf{x}}_{0}$, respectively. Notably, $\hat{{\mathbf{x}}}_{T}$ contains adversarial noise, while $\hat{{\mathbf{x}}}_{0}$ does not. To explicitly align the trajectory of $\hat{{\mathbf{x}}}_{t}$ with the starting and ending points, we introduce a coefficient $k_{t}$, such that $\hat{{\mathbf{x}}}_{t}:={\mathbf{x}}_{t}^{d}={\mathbf{x}}_{t}^{a}-k_{t}{
\boldsymbol{\epsilon}}_{a}$ for $0\leq t\leq T$, with $k_{0}=1$ and $k_{T}=0$.
With Bayes’ rule and the property of Gaussian distribution, we have

$$ $\displaystyle q({\mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{t}^{d},{\mathbf{x}}_{0})= \frac{q({\mathbf{x}}_{t}^{d}|{\mathbf{x}}_{t-1}^{d},{\mathbf{x}}_{0})\cdot q({ \mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{0})}{q({\mathbf{x}}_{t}^{d}|{\mathbf{x}}_{ 0})}\propto\exp\left(-\frac{1}{2}(A({\mathbf{x}}_{t-1}^{d})^{2}+B{\mathbf{x}}_ {t-1}^{d}+C)\right),$ (5) $$

where $A$ is a constant independent of ${\boldsymbol{\epsilon}}_{a}$, $B$ is the coefficient of ${\mathbf{x}}_{t-1}^{d}$ dependent on ${\boldsymbol{\epsilon}}_{a}$, and $C$ is a term without ${\mathbf{x}}_{t-1}^{d}$.
In inference, we expect that ${\boldsymbol{\epsilon}}_{a}$ in Eq. 5 can be eliminated since only ${\mathbf{x}}_{0}^{a}$ is given by attackers and ${\boldsymbol{\epsilon}}_{a}$ cannot be decoupled from ${\mathbf{x}}_{0}^{a}$ directly. Based on the property of Gaussian distribution, eliminating all terms related to ${\boldsymbol{\epsilon}}_{a}$ in $B$ and $C$ in Eq. 5 can be achieved by eliminating all terms related to ${\boldsymbol{\epsilon}}_{a}$ in $B$. This yields:

$$ $\frac{\sqrt{\alpha_{t}}(\sqrt{\alpha_{t}}k_{t-1}-k_{t}){\boldsymbol{\epsilon}} _{a}}{1-\alpha_{t}}-\frac{(\sqrt{\bar{\alpha}_{t-1}}-k_{t-1}){\boldsymbol{ \epsilon}}_{a}}{1-\bar{\alpha}_{t-1}}=0.$ (6) $$

To satisfy $k_{0}=1$, $k_{T}=0$, we can derive $k_{t}$ in Eq. 6 as:

$$ $k_{t}=\sqrt{\bar{\alpha}_{t}}-\frac{\bar{\alpha}_{T}(1-\bar{\alpha}_{t})}{ \sqrt{\bar{\alpha}_{t}}(1-\bar{\alpha}_{T})},0\leq t\leq T.$ (7) $$

For detailed derivations, please refer to Sec. B.1.

Following Eq. 3, ADBM uses ${\mathbf{x}}_{\theta}({\mathbf{x}}_{t}^{d},t):=\frac{1}{\sqrt{\bar{\alpha}_{t}
}}({\mathbf{x}}_{t}^{d}-\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}_{
\theta}({\mathbf{x}}_{t}^{d},t))$ to approximate the clean example ${\mathbf{x}}_{0}$. Thus the loss of ADBM can be computed by

$$ $\displaystyle L$ $\displaystyle=\mathbb{E}_{{\boldsymbol{\epsilon}},t}\|{\mathbf{x}}_{0}-{ \mathbf{x}}_{\theta}({\mathbf{x}}_{t}^{d},t)\|^{2}=\mathbb{E}_{{\boldsymbol{ \epsilon}},t}\left\|\frac{k_{t}-\sqrt{\bar{\alpha}_{t}}}{\sqrt{\bar{\alpha}_{t }}}{\boldsymbol{\epsilon}}_{a}-\frac{\sqrt{1-\bar{\alpha}_{t}}}{\sqrt{\bar{ \alpha}_{t}}}({\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({ \mathbf{x}}_{t}^{d},t))\right\|^{2}$ (8) $\displaystyle=\mathbb{E}_{{\boldsymbol{\epsilon}},t}\left[\frac{1-\bar{\alpha} _{t}}{\bar{\alpha}_{t}}\left\|\frac{\bar{\alpha}_{T}\sqrt{1-\bar{\alpha}_{t}}} {(1-\bar{\alpha}_{T})\sqrt{\bar{\alpha}_{t}}}{\boldsymbol{\epsilon}}_{a}+{ \boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t}^{d},t )\right\|^{2}\right].$ $$

Omitting $\frac{1-\bar{\alpha}_{t}}{\sqrt{\bar{\alpha}_{t}}}$ as in Ho et al. [], for a given ${\mathbf{x}}_{0}$, the final loss $L_{b}$ of ADBM is given by:

$$ $\displaystyle L_{b}=$ $\displaystyle\mathbb{E}_{{\boldsymbol{\epsilon}},t}\left[\left\|\frac{\bar{ \alpha}_{T}\sqrt{1-\bar{\alpha}_{t}}}{(1-\bar{\alpha}_{T})\sqrt{\bar{\alpha}_{ t}}}{\boldsymbol{\epsilon}}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon} }_{\theta}({\mathbf{x}}_{t}^{d},t)\right\|^{2}\right],$ (9) $$

where ${\mathbf{x}}_{t}^{d}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}+\sqrt{1-\bar{
\alpha}_{t}}{\boldsymbol{\epsilon}}+\frac{\bar{\alpha}_{T}(1-\bar{\alpha}_{t})
}{\sqrt{\bar{\alpha}_{t}}(1-\bar{\alpha}_{T})}{\boldsymbol{\epsilon}}_{a}$.
The training process of ADBM is detailed in the blue block of Figure 2.

Comparing Eq. 4 and Eq. 9, $L_{d}$ and $L_{b}$ are quite similar except that $L_{b}$ has two additional scaled ${\boldsymbol{\epsilon}}_{a}$ in both the input and prediction objective of ${\boldsymbol{\epsilon}}_{\theta}$. Thus in practice, the training of ADBM can fine-tune the pre-trained diffusion checkpoint with $L_{b}$, avoiding training from scratch. As $t$ decreases to 0, the coefficient of ${\boldsymbol{\epsilon}}_{a}$ diminishes. This complies with the intuition that ${\boldsymbol{\epsilon}}_{a}$ is gradually eliminated.

Figure: Figure 2: The illustration of ADBM training. The blue block represents the training objective, and the green block represents the extra module for adversarial noise generation. Black arrows denote the computation of $L_{b}$, blue arrows denote the computation of $L_{c}$ used for generating adversarial noise, and red arrows denote the direction of the gradient flow when calculating the adversarial noise.
Refer to caption: x2.png

### 4.2 Adversarial Noise Generation

We now proceed to the generation of adversarial noise required for ADBM training. A straightforward method for generating adversarial noise can be maximizing the loss $L_{b}$ of ADBM. However, the idea of deriving adversarial noise directly from the diffusion model itself might not align well with the objectives of the purification task. In this context, the primary goal is to ensure the classifier’s accuracy on images after they have been purified.

To better align with this goal, we propose to generate adversarial noise with the help of the classifier. During ADBM training, we input $\hat{{\mathbf{x}}}_{0}$ into the classifier, where $\hat{{\mathbf{x}}}_{0}=\frac{1}{\sqrt{\bar{\alpha}_{t}}}({\mathbf{x}}_{t}^{d}-
\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t}^{d}
,t))$. The classification loss $L_{c}$ is then given by $L_{c}(f_{\theta_{c}}(\hat{{\mathbf{x}}}_{0}),y)$, where $y$ denotes the category label of ${\mathbf{x}}_{0}$ and $f_{\theta_{c}}$ denotes the classifier. Finally, we compute $\frac{\partial L_{c}}{\partial{\boldsymbol{\epsilon}}_{a}}$ to obtain ${\boldsymbol{\epsilon}}_{a}$ that maximizes $L_{c}$.
Figure 2 illustrates this process with red arrows indicating the gradient flow direction for maximizing $L_{c}$.
Note that the parameters of the classifier are kept fixed during this process, ensuring that ADBM retains the plug-and-play functionality (without modifying the model to be protected) of AP methods.

Any gradient-based attack method generally can be used for maximizing $L_{c}$, but in practice, some particular proxy attack should be specified. Based on previous experiences, the PGD attack is a popular proxy that has a good generalization ability against various attacks during inference [, , ], and thus we also used such proxy attack in the ADBM training. Our experiments also validate that this proxy can generalize to other attacks such as AutoAttack, C&W [], and DeepFool [] attacks.
Note that during the training of ADBM, both $t$ and ${\boldsymbol{\epsilon}}$ in Eq. 9 are randomly sampled for each optimization step. This introduces a significant increase in computational cost when maximizing $L_{c}$ with PGD (EOT should be used). To address this issue, we propose an alternative method: instead of random sampling, we eliminate the randomness within a specific optimization step. In other words, for a given optimization step, we sample $t$ and ${\boldsymbol{\epsilon}}$ once and then fix their values throughout the entire training step (including generating ${\boldsymbol{\epsilon}}_{a}$ using methods like PGD and optimizing ${\boldsymbol{\epsilon}}_{\theta}$). This approach avoids the time-consuming EOT computation and ensures the calculation of adversarial noise that is truly effective for ADBM training. Note that we only eliminate randomness in the ADBM training. During inference, the randomness is kept, as discussed next.

### 4.3 AP Inference of ADBM

When using ADBM for AP, both the forward and reverse processes remain unchanged from the original pipeline of DiffPure, as shown in Figure 1(a). Any reverse samplers developed for diffusion models can be directly applied to the AP inference of ADBM without any modification, as ADBM only initiates the reverse process from a different starting point compared to traditional diffusion models. Therefore, to improve the practicality of ADBM, we can leverage fast sampling methods such as DDIM to accelerate the reverse process. As demonstrated in Sec. 3, the DDIM sampler efficiently conducts AP, even with a single reverse step.

### 4.4 Theoretical Analysis

We provide two theorems to show the superiority of ADBM for adversarial purification.

###### Theorem 1 .

Given an adversarial example ${\mathbf{x}}_{0}^{a}$ and assuming the training loss $L_{b}\leq\delta$, the distance between the purified example of ADBM and the clean example ${\mathbf{x}}_{0}$, denoted as $\|\hat{{\mathbf{x}}}_{0}-{\mathbf{x}}_{0}\|$, is bounded by $\delta$ (constant omitted) in expectation when using a one-step DDIM sampler. Specifically, we have $\mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\|\hat{{\mathbf{x}}}_{0}-{\mathbf{x}
}_{0}\|^{2}\right]\leq\frac{(1-\bar{\alpha}_{T})T}{{\bar{\alpha}_{T}}}\delta$, where $\frac{(1-\bar{\alpha}_{T})T}{{\bar{\alpha}_{T}}}$ is the constant.

###### Proof.

Please see the full proof in Sec. B.2.
∎

Theorem 1 implies that if the training loss of ADBM converges to zero, it can perfectly remove adversarial noises by employing a one-step DDIM sampler. While for DiffPure, we cannot derive such strong theoretical guarantee (The bound provided in Theorem 3.2 of Nie et al. [] is larger than $\|\epsilon_{a}\|$ and thus cannot be zero). Moreover, the subsequent theorem demonstrates the superiority of ADBM over DiffPure.

###### Theorem 2 .

Denote the probability of reversing the adversarial example to the clean example using ADBM and DiffPure as $P(B)$ and $P(D)$, respectively. Then $P(\cdot)=\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a}\}}p({
\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}){\mathrm{d}}{\mathbf{x}}_{0}$, where ${\mathbb{D}}_{a}$ denotes the set of adversarial examples.
If the timestep is infinite, the following inequality holds:

$$ $\displaystyle P(B)>P(D),$ $$

wherein

$$ $\displaystyle\mathrm{for\,}P(B):p({\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}) \propto\exp\left(-\frac{\|{\mathbf{x}}_{t}^{d}-\sqrt{\bar{\alpha}_{t}}{\mathbf {x}}_{0}^{a}\|^{2}}{2(1-\bar{\alpha}_{t})}\right),$ (10) $$

$$ $\displaystyle\mathrm{for\,}P(D):p({\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}) \propto\exp\left(-\frac{\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf {x}}_{0}\|^{2}}{2(1-\bar{\alpha}_{t})}\right).$ (11) $$

###### Proof.

(sketch) Eq. 10 and Eq. 11 are derived using Bayes’ rule, where $p({\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t})\propto p({\mathbf{x}}_{0})p(\hat{{
\mathbf{x}}}_{t}|{\mathbf{x}}_{0})$.
From the perspective of SDE, if timestep is infinite, $\{{\mathbf{x}}_{t}\}_{t:0\to T}$ and $\{\hat{{\mathbf{x}}}_{t}\}_{t:T\to 0}$ follow the same distribution [].
And given that $k_{t}<\sqrt{\bar{\alpha}}_{t}$ for any $1\leq t\leq T$, the inequality $P(B)>P(D)$ always holds.
Please see the full proof in Sec. B.3.
∎

Theorem 2 indicates that with infinite reverse timesteps, adversarial examples purified with ADBM are more likely to align with the clean data distribution than those with DiffPure.

###### Theorem 1 .

###### Proof.

###### Theorem 2 .

###### Proof.

## 5 Experiments

### 5.1 Experimental Settings

Datasets and network architectures.
We conducted comprehensive experiments on popular datasets, including SVHN [], CIFAR-10 [], and Tiny-ImageNet [], together with a large-scale dataset ImageNet-100 [].(^2^22We cannot afford to conduct experiments on the full ImageNet-1K []. As an alternative, we used ImageNet-100, a curated subset of ImageNet-1K featuring 100 categories with the original resolution of ImageNet-1K.) All these datasets consist of RGB images, whose resolution is $32\times 32$ for SVHN and CIFAR-10, $64\times 64$ for Tiny-ImageNet, and $224\times 224$ for ImageNet-100.
We adopted the widely used WideResNet-28-10 (WRN-28-10), WRN-70-16, WRN-28-10, and ResNet-50 [] architectures as classifiers on SVHN, CIFAR-10, Tiny-ImageNet, and ImageNet-100, respectively. As for the diffusion models, we employed the UNet architecture [] improved by Song et al. [], specifically, the DDPM++ continuous variant. Pre-trained diffusion checkpoints are required for DiffPure. We directly used the checkpoint provided by Song et al. [] for CIFAR-10 and we used their code to train the checkpoints for other datasets. These trained checkpoints were used in DiffPure and served as baselines for ADBM.

Fine-tuning settings of ADBM.
The adversarial noise was computed in the popular norm-ball setting $\|{\boldsymbol{\epsilon}}_{a}\|_{\infty}\leq 8/255$. When computing ${\boldsymbol{\epsilon}}_{a}$, we used PGD with three iteration steps and a step size of $8/255$. Other settings followed the standard configuration used in Song et al. []. The fine-tuning steps were set to 30K, which is about 1/10 the training steps of the original diffusion models. In each fine-tuning step, the value of $T$ in Eq. 9 was uniformly sampled from 100 to 200. Note that when fine-tuning the diffusion models, the parameters of the classifier were kept frozen. Additional settings are provided in Sec. C.1.

Defense configurations of ADBM.
Unless otherwise specified, the forward diffusion steps were set to be 100 for SVHN and CIFAR-10 and 150 for Tiny-ImageNet and ImageNet-100, respectively. The reverse steps were set to be five. The reverse process used a DDIM sampler. These configurations were also applied to DiffPure for a fair comparison.

**Table 3: Accuracies (%) of methods under different adaptive attack threats on CIFAR-10. Average denotes the average accuracies under three attack threats. Vanilla denotes the vanilla model without any defense mechanism. The best results in each column for robust accuracy are highlighted.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ norm | $l_{1}$ norm | $l_{2}$ norm | Average |  |  |  |  |
| WRN-70-16 | Vanilla | - | $97.02$ | $0.00$ | $0.00$ | $0.00$ | $0.00$ |
| WRN-70-16 | [] | AT | $91.10$ | $65.92$ | $8.26$ | $27.56$ | $33.91$ |
| WRN-70-16 | [] | $88.54$ | $64.26$ | $12.06$ | $32.29$ | $36.20$ |  |
| WRN-70-16 | Augment w/ Diff [] | $88.74$ | $66.18$ | $9.76$ | $28.73$ | $34.89$ |  |
| WRN-70-16 | Augment w/ Diff [] | $93.25$ | 70.72 | $8.48$ | $28.98$ | $36.06$ |  |
| MLP+WRN-28-10 | [] | AP | $91.89$ | $4.56$ | $8.68$ | $7.25$ | $6.83$ |
| UNet+WRN-70-16 | [] | $87.93$ | $37.65$ | $36.87$ | $57.81$ | $44.11$ |  |
| UNet+WRN-70-16 | DiffPure+Guide [] | $93.16$ | $22.07$ | $28.71$ | $35.74$ | $28.84$ |  |
| UNet+WRN-70-16 | Diff+ScoreOpt [] | $91.41$ | $13.28$ | $10.94$ | $28.91$ | $17.71$ |  |
| UNet+WRN-70-16 | DiffPure+Langevin [] | $92.18$ | $43.75$ | $39.84$ | $55.47$ | $46.35$ |  |
| UNet+WRN-70-16 | DiffPure [] | $92.5\pm 0.5$ | $42.2\pm 2.1$ | $44.3\pm 1.3$ | $60.8\pm 2.3$ | $49.1\pm 1.7$ |  |
| UNet+WRN-70-16 | ADBM (Ours) | $91.9\pm 0.8$ | $47.7\pm 2.2$ | $\textbf{49.6}\pm 2.2$ | $\textbf{63.3}\pm 1.9$ | $\textbf{53.5}\pm 2.1$ |  |

### 5.2 Robustness against White-Box Adaptive Attacks

We first evaluate ADBM against the reliable while-box adaptive attacks to show the worst-case adversarial robustness where the attacker has complete knowledge. Note that we expect a defense method to be robust not only on seen threats but also on unseen attack threats. Thus, unless otherwise specified, we evaluated the models on three attack threats: $l_{\infty}$, $l_{1}$, and $l_{2}$, with the bounds $\epsilon_{\infty}=8/255$, $\epsilon_{1}=12$, $\epsilon_{2}=1$, respectively. Here $l_{\infty}$ attack is considered the seen threat as ADBM was trained with $l_{\infty}$ adversarial noise, while $l_{1}$ and $l_{2}$ attacks can be regarded as unseen threats.

We compared ADBM with SOTA AT and AP methods. All AT models were trained also with $l_{\infty}$ adversarial examples only, ensuring $l_{1}$ and $l_{2}$ threats were unseen for these models. We used AutoAttack [] to implement the adversarial threats for AT methods, while we used the attack practice described in Sec. 3 (PGD with 200 iteration steps and 20 EOT samples) to implement the adversarial threats for AP methods. Additional configurations of these attacks can be found in Sec. C.2. Note that this evaluation comparison is justified since Lee and Kim [] observed that AutoAttack with EOT yielded inferior attack performance compared to PGD with EOT for stochastic pre-processing defenses.
Our experiments in Sec. D.1 further confirmed that PGD with EOT is the best practice than other attacks such as AutoAttack, C&W, and DeepFool with EOT.

The accuracies under the reliable white-box adaptive attacks on CIFAR-10 are shown in Tab. 3.
In this evaluation, we compared ADBM with several competitive methods.
Both Gowal et al. [] and Wang et al. [] performed AT with about 50M generated images by diffusion models.
Additionally, we compared ADBM with several AP methods using generative models, especially diffusion models.
By inspecting these results, we can see that despite training with millions of examples, AT methods still exhibited limited robustness against unseen $l_{1}$ and $l_{2}$ attacks. In contrast, ADBM demonstrates a strong defense against $l_{1}$ and $l_{2}$ attacks. Moreover, attempts to enhance the performance of DiffPure by introducing input guidance [] or applying Langevin dynamics [] occasionally resulted in detrimental effects when assessed through reliable adaptive attack evaluations. Notably, ADBM outperformed DiffPure by achieving an average robustness gain of 4.4% on CIFAR-10, while the clean accuracies kept comparable. Similar outcomes were observed for SVHN, Tiny-ImageNet, and ImageNet-100, detailed in Sec. D.2, reinforcing similar findings from the CIFAR-10 analyses.

**Table 4: Accuracies ($\%$) of methods under three query-based attacks and the transfer-based attack on SVHN. Average denotes the average accuracies under four attacks. All attacks are performed with the $l_{\infty}$ bound $8/255$.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| RayS | Square | SPSA | Transfer | Average |  |  |  |  |
| WRN-28-10 | Vanilla | - | $98.11$ | $16.89$ | $9.08$ | $13.48$ | - | - |
| WRN-28-10 | [] | AT | $94.46$ | $68.90$ | $58.96$ | $74.22$ | $87.60$ | $76.83$ |
| WRN-28-10 | [] | $93.00$ | $62.30$ | $60.49$ | $71.78$ | $87.60$ | $75.53$ |  |
| WRN-28-10 | [] | $95.56$ | $75.16$ | $67.23$ | $80.39$ | $88.57$ | $81.38$ |  |
| UNet+WRN-28-10 | DiffPure [] | AP | $93.93$ | $92.97$ | $92.15$ | $92.19$ | $91.49$ | $92.20$ |
| UNet+WRN-28-10 | ADBM (Ours) | $93.49$ | 93.16 | 93.32 | 93.49 | 92.88 | 93.21 |  |

### 5.3 Robustness against Black-Box Attacks

We then considered the more realistic black-box attacks, where the attacker has no knowledge about the defense mechanism, i.e., the purification model, and cannot access the gradients of models. Instead, the attacker can only query the model’s output with query-based attacks or use substitute models with transfer-based attacks. We conducted three query-based attacks: Square [], RayS [], and SPSA [] attacks. Square and RayS are efficient search-based attack methods, while SPSA approximates gradients by sampling randomly in a black-box manner. For Square and RayS, we utilized 5,000 search steps. In the SPSA attack, we set $\sigma$ to 0.001, the number of random samples in each iteration step to 128, and the iteration step to 40. The transfer-based attack was implemented by generating adversarial examples via the vanilla models.

The results under black-box attacks on SVHN and CIFAR-10 are shown in Tab. 4 and Sec. D.3, respectively. We can see that these black-box attacks achieved excellent attack performance on the vanilla model. For the SOTA AT method [] on SVHN, these attacks lowered the average accuracy to 81.38%. But surprisingly, all these black-box attacks can hardly lower the accuracies of ADBM. Thus, we can conclude that besides the promising results on white-box attacks, under the realistic black-box attacks, ADBM has advantages over AT models even on the seen threat (i.e., $l_{\infty}$ threat).

**Table 5: Accuracies (%) of methods under different adaptive attack threats on CIFAR-10. The same conventions are used as in Tab. A4.**
| Method | Reverse | Clean | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| Step | $l_{\infty}$ | $l_{1}$ | $l_{2}$ | Average |  |  |
| DiffPure | 5 | $92.5$ | $42.2$ | $44.3$ | $60.8$ | $49.1$ |
| 2 | $92.3$ | $42.7$ | $44.5$ | $60.9$ | $49.4$ |  |
| 1 | $92.3$ | $43.0$ | $45.2$ | $59.6$ | $49.3$ |  |
| ADBM | 5 | $91.9$ | 47.7 | $49.6$ | 63.3 | 53.5 |
| 2 | $91.9$ | 47.7 | $49.2$ | $63.2$ | $53.3$ |  |
| 1 | $91.5$ | $45.7$ | 50.7 | $61.9$ | $52.8$ |  |

### 5.4 Ablation Study

The ablation studies were performed on CIFAR-10. The evaluation followed the setting in Sec. 5.2.

Reverse steps. We first investigated the influence of reverse steps on the adversarial robustness of ADBM. The number of reverse steps is proportional to the inference cost. We used five reverse steps in the main experiments. Here we evaluated the robustness of ADBM with fewer steps to investigate whether the number of steps can be further reduced. The results in Tab. 6 show ADBM was more robust than DiffPure regardless of reverse steps. Notably, even with just one reverse step, ADBM maintained its good robustness. We discuss the detailed inference cost related to this further in Sec. 6.

Adversarial noise generation modes. We then analyzed the impact of different adversarial noise generation modes for ADBM. As discussed in Sec. 4.2, adversarial noise used for training ADBM can be generated by various modes. We analyzed the contributions of our three key design choices in the generation modes: using the classifier, fixing $t$, and fixing ${\mathbf{x}}$. The results shown in Tab. 6 clearly demonstrate that all of these designs are essential for the success of ADBM. Removing any of these designs hampers the proper computation of adversarial noise for ADBM training.

Effectiveness on new classifiers. To assess the effectiveness of ADBM on new classifiers, we conducted a study to investigate its transferability. Specifically, we utilized the fine-tuned ADBM checkpoint, trained with adversarial noise from a WRN-70-16 classifier, as the pre-processor for a WRN-28-10 model and a vision transformer model [] directly, denoted as ADBM(Transfer). The results shown in Sec. D.4 demonstrate that ADBM(Transfer) achieved robust accuracies comparable to ADBM directly trained with corresponding classifiers. This finding highlights the practicality of ADBM, as the fine-tuned ADBM model on a specific classifier can potentially be directly applied to a new classifier without requiring retraining. We guess this may be attributed to the transferability of adversarial noise [].

## 6 Conclusion and Discussion

In this work, we introduce ADBM, a cutting-edge method for diffusion-based adversarial purification. Theoretical analysis supports the superiority of ADBM in enhancing adversarial robustness. With extensive experiments, we demonstrated the effectiveness of ADBM across various scenarios using reliable adaptive attacks. Notably, ADBM demonstrates significant improvements over prevalent AT methods against unseen threats or black-box attacks. In the era of foundation models [], training foundation models with AT becomes increasingly challenging due to high computational costs. ADBM, on the other hand, provides a promising alternative as a plug-and-play component that can enhance the robustness of existing foundation models without the burdensome of retraining. The social impact of this work is discussed in Appendix E.

Limitation. While ADBM requires quite few reverse steps, it does introduce additional computational demands due to its reliance on diffusion models. The current UNet architectures, tailored primarily for generative purposes, are quite large (see Sec. D.5). Exploring the potential of downsizing these architectures for AP remains an open area for future research.

## Appendix A Evaluations on DiffPure

### A.1 Previous Evaluation Methods on DiffPure

As the original implementation of DiffPure needs dozens of prediction steps in the reverse process, it is challenging to compute the full gradient of the whole purification process due to memory constraints. To circumvent computing the full gradient, Nie et al. [] originally employed the adjoint method (along with Expectation over Transformation (EOT) []) to compute an approximate gradient. But recent works have identified it to be a flawed adaptive attack [, ]. As improved adaptive mechanisms, Lee and Kim [] proposed a surrogate attack for DiffPure (to approximate the gradient of the iterative reverse procedure better) and Chen et al. [] utilized the gradient-checkpointing technique [] to trade time for memory space and compute the full gradient directly. Despite previous efforts, we find that the adaptive evaluations for DiffPure remained insufficient. Specifically, the surrogate attack failed to compute the full gradient, and the gradient-checkpointing attack in Chen et al. [] employed insufficient iteration steps or EOT samples, an issue underscored by Gao et al. [] which highlights the importance of adequate steps and samples for evaluating stochastic pre-processing defenses like DiffPure.

### A.2 The Cost of Our Evaluation

In our evaluation, we used the full gradient of the whole reverse process and set the PGD iteration steps to 200, with 20 EOT samples for each iteration. The cost of the evaluation is quite high, especially in the context of the high reverse steps of the original DiffPure. To give a concrete example, for a single input image, the noise prediction model (i.e., ${\boldsymbol{\epsilon}}_{\theta}$) in the original DiffPure implementation with 100 reverse steps needs to be queried a total of $400,000$ times.

However, we think that such high efforts are worthwhile as an unreliable evaluation could create a false sense of security on defenses. Historical evidence has shown that many defenses initially considered robust, were subsequently breached by more sophisticated and dedicated attacks [, ]. Our aim is to prevent a similar outcome for diffusion-based purification, advocating for the employment of a meticulous and reliable attack evaluation methodology, regardless of the expense involved.

On the other hand, with our reliable evaluation, we have investigated the influence of forward steps and reverse steps on the robustness of diffusion-based purification. Our following results in Tab. 2 indicate that reverse steps will not significantly influence the robustness of DiffPure under the reliable evaluation. This suggests that diffusion-based purification techniques might not benefit from increasing the number of reverse steps to complicate the attack process, as such strategies could finally be neutralized by high-cost attacks similar to the one we have implemented. And when the reverse steps are reduced (e.g., five steps in our main experiments), the attack cost of our evaluation method is comparable to the most widely used AutoAttack benchmark [].

### A.3 Additional Investigation on DiffPure with Our Evaluation

As shown in Tab. 2, we find that the reverse step does not significantly affect the robustness when using the DDIM sampler. Considering the computational cost of attacks, we fixed the reverse step to 5 with the DDIM sampler and focused on investigating the influence of forward steps on robustness. The results are shown in Tab. A1. We observed a continuous decrease in clean accuracy and a continuous increase in robustness as the number of forward steps increased. This can be attributed to the introduction of more noise during the forward process.

**Table A1: Accuracies of DiffPure on CIFAR-10 with reverse step 5, varying forward steps, and using DDIM sampler. The robust accuracy was evaluated under an $l_{\infty}$ bound of $\epsilon_{\infty}=8/255$.**
| Forward Step | 100 | 110 | 120 | 130 | 140 | 150 |
| --- | --- | --- | --- | --- | --- | --- |
| Clean Acc | 92.38 | $91.21$ | $91.01$ | $89.84$ | $89.45$ | $87.89$ |
| Robust Acc | $42.16$ | $43.75$ | $44.53$ | $47.85$ | $48.43$ | 49.02 |

## Appendix B Derivation of Equations and Proofs of Theorems

### B.1 The Derivation of Eq. 7

###### Proof.

Following the Bayes’ rule, we have

$$ $q({\mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{t}^{d},{\mathbf{x}}_{0})=\frac{q({ \mathbf{x}}_{t}^{d}|{\mathbf{x}}_{t-1}^{d},{\mathbf{x}}_{0})\cdot q({\mathbf{x }}_{t-1}^{d}|{\mathbf{x}}_{0})}{q({\mathbf{x}}_{t}^{d}|{\mathbf{x}}_{0})}$ (12) $$

Since ${\mathbf{x}}_{t}^{d}={\mathbf{x}}_{t}^{a}-k_{t}{\boldsymbol{\epsilon}}_{a}$ and ${\mathbf{x}}_{t}^{a}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{
\alpha}_{t}}{\boldsymbol{\epsilon}}$, there is

$$ ${\mathbf{x}}_{t}^{d}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}+\sqrt{1-\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}+(\sqrt{\bar{\alpha}_{t}}-k_{t}){ \boldsymbol{\epsilon}}_{a}.$ (13) $$

Based on the property of Gaussian distribution, $p({\mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{t}^{d},{\mathbf{x}}_{0})$ also must be Gaussian distribution, thus,

$$ $\displaystyle q({\mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{t}^{d},{\mathbf{x}}_{0})$ $\displaystyle=\frac{q({\mathbf{x}}_{t}^{d}|{\mathbf{x}}_{t-1}^{d},{\mathbf{x}} _{0})\cdot q({\mathbf{x}}_{t-1}^{d}|{\mathbf{x}}_{0})}{q({\mathbf{x}}_{t}^{d}| {\mathbf{x}}_{0})}\propto\exp(-\frac{1}{2}(\frac{({\mathbf{x}}_{t}^{d}-\sqrt{ \alpha_{t}}{\mathbf{x}}_{t-1}^{d}-(\sqrt{\alpha_{t}}k_{t-1}-k_{t}){\boldsymbol {\epsilon}}_{a})^{2}}{1-\alpha_{t}}$ (14) $\displaystyle+\frac{({\mathbf{x}}_{t-1}^{d}-\sqrt{\bar{\alpha}_{t-1}}{\mathbf{ x}}_{0}-(\sqrt{\bar{\alpha}_{t-1}}-k_{t-1}){\boldsymbol{\epsilon}}_{a})^{2}}{1 -\bar{\alpha}_{t-1}}-\frac{({\mathbf{x}}_{t}^{d}-\sqrt{\bar{\alpha}_{t}}{ \mathbf{x}}_{0}-(\sqrt{\bar{\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a})^{2 }}{1-\bar{\alpha}_{t}}))$ $\displaystyle=\exp\left(-\frac{1}{2}(A({\mathbf{x}}_{t-1}^{d})^{2}+B{\mathbf{x }}_{t-1}^{d}+C({\mathbf{x}}_{0},{\boldsymbol{\epsilon}}_{a},{\mathbf{x}}_{t}^{ d}))\right),$ $$

where

$$ $\displaystyle A=\frac{\alpha_{t}}{1-\alpha_{t}}+\frac{1}{1-\bar{\alpha}_{t-1}} =\frac{1-\bar{\alpha}_{t}}{(1-\alpha_{t})(1-\bar{\alpha}_{t-1})},$ (15) $\displaystyle B=-2\sqrt{\alpha_{t}}\cdot\frac{{\mathbf{x}}_{t}^{d}-(\sqrt{ \alpha_{t}}k_{t-1}-k_{t}){\boldsymbol{\epsilon}}_{a}}{1-\alpha_{t}}-2\frac{ \sqrt{\bar{\alpha}_{t-1}}{\mathbf{x}}_{0}+(\sqrt{\bar{\alpha}_{t-1}}-k_{t-1}){ \boldsymbol{\epsilon}}_{a}}{1-\bar{\alpha}_{t-1}}.$ $$

In inference, we expect that ${\boldsymbol{\epsilon}}_{a}$ in Eq. 14 can be eliminated since only ${\mathbf{x}}_{0}^{a}$ is given by attackers and ${\boldsymbol{\epsilon}}_{a}$ cannot be decoupled from ${\mathbf{x}}_{0}^{a}$ directly. Based on the property of Gaussian distribution, eliminating all terms related to ${\boldsymbol{\epsilon}}_{a}$ in $B$ and $C$ in Eq. 5 can be achieved by eliminating all terms related to ${\boldsymbol{\epsilon}}_{a}$ in $B$. This yields:

$$ $\frac{\sqrt{\alpha_{t}}(\sqrt{\alpha_{t}}k_{t-1}-k_{t}){\boldsymbol{\epsilon}} _{a}}{1-\alpha_{t}}-\frac{(\sqrt{\bar{\alpha}_{t-1}}-k_{t-1}){\boldsymbol{ \epsilon}}_{a}}{1-\bar{\alpha}_{t-1}}=0.$ (16) $$

Although Eq. 16 cannot be directly solved, we can derive its recurrent form. Let us set $k_{t}=\sqrt{\bar{\alpha}_{t}}\gamma_{t}$, where $0\leq t\leq T$ and $\gamma_{0}=1,\gamma_{T}=0$.
The Eq. 16 can deduce to

$$ $\frac{\sqrt{\alpha_{t}}}{1-\alpha_{t}}(\sqrt{\bar{\alpha}_{t}}\gamma_{t-1}- \sqrt{\bar{\alpha}_{t}}\gamma_{t})=\frac{\sqrt{\bar{\alpha}_{t-1}}-\sqrt{\bar{ \alpha}_{t-1}}\gamma_{t-1}}{1-\bar{\alpha}_{t-1}}.$ (17) $$

Then group the items according to timestep ($t$ and $t-1$):

$$ $\left(\frac{\alpha_{t}}{1-\alpha_{t}}+\frac{1}{1-\bar{\alpha}_{t-1}}\right) \gamma_{t-1}=\frac{1}{1-\bar{\alpha}_{t-1}}+\frac{\alpha_{t}}{1-\alpha_{t}} \gamma_{t}.$ (18) $$

Now we have a recurrent equation about $\gamma_{t}$. The equivalence holds for all $0<t\leq T$.
Therefore, by elucidating the relationship between $\gamma_{t}$ and the initial value $\gamma_{1}$, we can deduce an expression for each $\gamma_{t}$.
If we reorganize items in Eq. 18, it yields a recurrent equation:

$$ $\displaystyle\gamma_{t}-1$ $\displaystyle=\frac{\alpha_{t}-\bar{\alpha}_{t}}{1-\bar{\alpha}_{t}}(\gamma_{t -1}-1)$ (19) $\displaystyle=\prod_{i=2}^{t}\frac{\alpha_{i}-\bar{\alpha}_{i}}{1-\bar{\alpha} _{i}}(\gamma_{1}-1)$ $\displaystyle=\frac{\bar{\alpha}_{1}(1-\bar{\alpha}_{t})}{\bar{\alpha}_{t}(1- \bar{\alpha}_{1})}(\gamma_{1}-1).$ $$

Since $\gamma_{T}=0$, we have the expression of $\gamma_{1}$ when $t=T$:

$$ $\displaystyle\gamma_{T}-1$ $\displaystyle=\frac{\bar{\alpha}_{1}(1-\bar{\alpha}_{T})}{\bar{\alpha}_{T}(1- \bar{\alpha}_{1})}(\gamma_{1}-1),$ (20) $\displaystyle\gamma_{1}$ $\displaystyle=1-\frac{\bar{\alpha}_{T}(1-\bar{\alpha}_{1})}{\bar{\alpha}_{1}(1 -\bar{\alpha}_{T})}$ $$

and $\gamma_{t}$ generated from $\gamma_{1}$ is

$$ $\gamma_{t}=1-\frac{\bar{\alpha}_{T}(1-\bar{\alpha}_{t})}{\bar{\alpha}_{t}(1- \bar{\alpha}_{T})}.$ (21) $$

Recalling that $k_{t}=\sqrt{\bar{\alpha}_{t}}\gamma_{t}$, we thus have

$$ $k_{t}=\sqrt{\bar{\alpha}_{t}}\gamma_{t}=\sqrt{\bar{\alpha}_{t}}-\frac{\bar{ \alpha}_{T}(1-\bar{\alpha}_{t})}{\sqrt{\bar{\alpha}_{t}}(1-\bar{\alpha}_{T})}, \quad 0\leq t\leq T.$ (22) $$

∎

###### Proof.

### B.2 The Proof of Theorem 1

###### Theorem 1 .

Given an adversarial example ${\mathbf{x}}_{0}^{a}$ and assuming the training loss $L_{b}\leq\delta$, the distance between the purified example of ADBM and the clean example ${\mathbf{x}}_{0}$, denoted as $\|\hat{{\mathbf{x}}}_{0}-{\mathbf{x}}_{0}\|$, is bounded by $\delta$ in expectation (constant omitted) when using a one-step DDIM sampler. Specifically, we have $\mathbb{E}_{{\boldsymbol{\epsilon}}}[\|\hat{{\mathbf{x}}}_{0}-{\mathbf{x}}_{0}
\|^{2}]\leq\frac{(1-\bar{\alpha}_{T})T}{{\bar{\alpha}_{T}}}\delta$, where $\frac{(1-\bar{\alpha}_{T})T}{{\bar{\alpha}_{T}}}$ is the constant.

###### Proof.

This inequality holds when we use the DDIM reverse sampler and set the reverse step $s=1$. According to Song et al. [], the reverse process of DDIM is

$$ $\hat{{\mathbf{x}}}_{\tau_{i-1}}=\sqrt{\bar{\alpha}_{\tau_{i-1}}}\left(\frac{ \hat{{\mathbf{x}}}_{\tau_{i}}-\sqrt{1-\bar{\alpha}_{\tau_{i}}}{\boldsymbol{ \epsilon}}_{\theta}(\hat{{\mathbf{x}}}_{\tau_{i}},\tau_{i})}{\sqrt{\bar{\alpha }_{\tau_{i}}}}\right)+\sqrt{1-\bar{\alpha}_{\tau_{i-1}}}{\boldsymbol{\epsilon} }_{\theta}(\hat{{\mathbf{x}}}_{\tau_{i}},\tau_{i}),$ (23) $$

where $\{\tau_{0},\ldots,\tau_{s}\}$ is a linearly increasing sub-sequence of $[0,\ldots,t]$, $\tau_{0}=1,\tau_{s}=t$. Setting $s=1$, then it yields:

$$ $\hat{{\mathbf{x}}}_{0}=\sqrt{\bar{\alpha}_{0}}\left(\frac{{\mathbf{x}}_{t}^{a} -\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t}^{a },t)}{\sqrt{\bar{\alpha}_{t}}}\right)+\sqrt{1-\bar{\alpha}_{0}}{\boldsymbol{ \epsilon}}_{\theta}({\mathbf{x}}_{t}^{a},t).$ (24) $$

Since $\sqrt{\bar{\alpha}_{0}}=1$, ${\mathbf{x}}_{t}^{a}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{
\alpha}_{t}}{\boldsymbol{\epsilon}}$, ${\mathbf{x}}_{0}^{a}={\mathbf{x}}_{0}+{\boldsymbol{\epsilon}}_{a}$, and $t=T$, Eq. 24 can be written as

$$ $\displaystyle\hat{{\mathbf{x}}}_{0}$ $\displaystyle={\mathbf{x}}_{0}^{a}+\frac{\sqrt{1-\bar{\alpha}_{T}}}{\sqrt{\bar {\alpha}_{T}}}({\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({ \mathbf{x}}_{T}^{a},T))$ (25) $\displaystyle={\mathbf{x}}_{0}+\frac{\sqrt{1-\bar{\alpha}_{T}}}{\sqrt{\bar{ \alpha}_{T}}}(\frac{\sqrt{\bar{\alpha}_{T}}}{\sqrt{1-\bar{\alpha}_{T}}}{ \boldsymbol{\epsilon}}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{ \theta}({\mathbf{x}}_{T}^{a},T)).$ $$

Therefore, the distance between $\hat{{\mathbf{x}}}_{0}$ and ${\mathbf{x}}_{0}$ is

$$ $\displaystyle\|\hat{{\mathbf{x}}}_{0}-{\mathbf{x}}_{0}\|$ $\displaystyle=\frac{\sqrt{1-\bar{\alpha}_{T}}}{\sqrt{\bar{\alpha}_{T}}}\left\| \frac{\sqrt{\bar{\alpha}_{T}}}{\sqrt{1-\bar{\alpha}_{T}}}{\boldsymbol{\epsilon }}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{ T}^{a},T)\right\|$ (26) $\displaystyle=\frac{\sqrt{1-\bar{\alpha}_{T}}}{\sqrt{\bar{\alpha}_{T}}}\left\| \frac{\sqrt{\bar{\alpha}_{T}}}{\sqrt{1-\bar{\alpha}_{T}}}{\boldsymbol{\epsilon }}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{ T}^{d},T)\right\|,$ $$

where the second equivalence holds due to $t=T$ and ${\mathbf{x}}_{T}^{d}={\mathbf{x}}_{T}^{a}-k_{T}{\boldsymbol{\epsilon}}_{a}={
\mathbf{x}}_{T}^{a}$.
Considering that

$$ $\displaystyle L_{b}$ $\displaystyle=\mathbb{E}_{{\boldsymbol{\epsilon}},t}\left[\left\|\frac{\sqrt{1 -\bar{\alpha}_{t}}}{\sqrt{\bar{\alpha}_{t}}}\cdot\frac{\bar{\alpha}_{t}}{1- \bar{\alpha}_{t}}{\boldsymbol{\epsilon}}_{a}+{\boldsymbol{\epsilon}}-{ \boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t}^{d},t)\right\|^{2}\right]$ (27) $\displaystyle=\frac{1}{T}\sum_{t=0}^{T}\mathbb{E}_{{\boldsymbol{\epsilon}}} \left[\left\|\frac{\sqrt{1-\bar{\alpha}_{t}}}{\sqrt{\bar{\alpha}_{t}}}\cdot \frac{\bar{\alpha}_{t}}{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}_{a}+{ \boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{\theta}({\mathbf{x}}_{t}^{d},t )\right\|^{2}\right]$ $\displaystyle\leq\delta,$ $$

thus

$$ $\mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\frac{{1-\bar{\alpha}_{T}}}{{\bar{ \alpha}_{T}}}\left\|\frac{\sqrt{\bar{\alpha}_{T}}}{\sqrt{1-\bar{\alpha}_{T}}}{ \boldsymbol{\epsilon}}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{\epsilon}}_{ \theta}({\mathbf{x}}_{T}^{d},T)\right\|^{2}\right]\leq T\cdot\delta$ (28) $$

Then we have

$$ $\displaystyle\mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\left|\hat{{\mathbf{x}} }_{0}-{\mathbf{x}}_{0}\right\|^{2}\right]$ $\displaystyle=\mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\frac{{1-\bar{\alpha}_ {T}}}{{\bar{\alpha}_{T}}}\left\|\frac{\sqrt{\bar{\alpha}_{T}}}{\sqrt{1-\bar{ \alpha}_{T}}}{\boldsymbol{\epsilon}}_{a}+{\boldsymbol{\epsilon}}-{\boldsymbol{ \epsilon}}_{\theta}({\mathbf{x}}_{T}^{d},T)\right\|^{2}\right]$ (29) $\displaystyle\leq\frac{(1-\bar{\alpha}_{T})T}{{\bar{\alpha}_{T}}}\delta.$ $$

∎

###### Theorem 1 .

###### Proof.

### B.3 The Proof of Theorem 2

###### Theorem 2 .

Denote the probability of reversing the adversarial example to the clean example using ADBM and DiffPure as $P(B)$ and $P(D)$, respectively. Then $P(\cdot)$ can be computed as $P(\cdot)=\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a}\}}p({
\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}){\mathrm{d}}{\mathbf{x}}_{0}$, where ${\mathbb{D}}_{a}$ denotes the set of adversarial examples.
If the timestep is infinite, the following inequality holds:

$$ $\displaystyle P(B)>P(D),$ $$

wherein

$$ $\displaystyle\mathrm{for\,}P(B):p({\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}) \propto\exp\left(-\frac{\|{\mathbf{x}}_{t}^{d}-\sqrt{\bar{\alpha}_{t}}{\mathbf {x}}_{0}^{a}\|^{2}}{2(1-\bar{\alpha}_{t})}\right),$ (30) $$

$$ $\displaystyle\mathrm{for\,}P(D):p({\mathbf{x}}_{0}|\hat{{\mathbf{x}}}_{t}) \propto\exp\left(-\frac{\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf {x}}_{0}\|^{2}}{2(1-\bar{\alpha}_{t})}\right).$ (31) $$

###### Proof.

The concept of infinite timestep can be viewed as dividing a finite length of time into infinitesimal intervals, which corresponds to the situation of the following SDEs proposed by Song et al. [].
Denoting ${\mathbf{w}}$ as the standard Wiener process, $\bar{{\mathbf{w}}}$ as the reverse-time standard Wiener process, and $p_{t}({\mathbf{x}})$ the probability density of ${\mathbf{x}}_{t}$, the forward process can be described by

$$ ${\mathrm{d}}{\mathbf{x}}=f({\mathbf{x}},t){\mathrm{d}}t+g(t){\mathrm{d}}{ \mathbf{w}},$ (32) $$

where $f({\mathbf{x}},t)$ and $g(t)$ denote the drift and diffusion coefficients, respectively. Under mild assumptions, the reverse process can be derived from:

$$ ${\mathrm{d}}{\mathbf{x}}=[f({\mathbf{x}},t){\mathrm{d}}t-g(t)^{2}\nabla_{{ \mathbf{x}}}\log p_{t}({\mathbf{x}})]{\mathrm{d}}t+g(t){\mathrm{d}}\bar{{ \mathbf{w}}}.$ (33) $$

In this context, the reverse of a diffusion process is also a diffusion process, running backwards in time and given by the reverse-time SDE (Eq. 33).
Therefore, if timestep is infinite, $\{{\mathbf{x}}_{t}\}_{t:0\to T}$ and $\{\hat{{\mathbf{x}}}_{t}\}_{t:T\to 0}$, as the solutions of Eq. 32 and Eq. 33 respectively, follow the same distribution.
And due to the Bayes’ rule,

$$ $\displaystyle p({{\mathbf{x}}}_{0}|\hat{{\mathbf{x}}}_{t})$ $\displaystyle=p({{\mathbf{x}}}_{0})\frac{p(\hat{{\mathbf{x}}}_{t}|{{\mathbf{x} }}_{0})}{p(\hat{{\mathbf{x}}}_{t})}$ (34) $\displaystyle=p({\mathbf{x}}_{0})\frac{p({{\mathbf{x}}}_{t}|{{\mathbf{x}}}_{0} )}{p(\hat{{\mathbf{x}}}_{t})}$ $\displaystyle\propto p({\mathbf{x}}_{0})p({\mathbf{x}}_{t}|{\mathbf{x}}_{0})$ $$

Since $\hat{{\mathbf{x}}}_{t}:={\mathbf{x}}_{t}^{d}$ in ADBM and $\hat{{\mathbf{x}}}_{t}:={\mathbf{x}}_{t}^{a}$ in DiffPure,
then for all the examples,

$$ $\displaystyle P(B)$ $\displaystyle=\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a}\}}p({{ \mathbf{x}}}_{0}|\hat{{\mathbf{x}}}_{t}){\mathrm{d}}{\mathbf{x}}_{0}$ (35) $\displaystyle\propto\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a} \}}p({\mathbf{x}}_{0})p({\mathbf{x}}_{t}^{d}|{\mathbf{x}}_{0}){\mathrm{d}}{ \mathbf{x}}_{0}$ $\displaystyle\propto\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a} \}}\exp\left(-\frac{\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}} _{0}-(\sqrt{\bar{\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a}\|^{2}}{2(1- \bar{\alpha}_{t})}\right)p({\mathbf{x}}_{0}){\mathrm{d}}{\mathbf{x}}_{0}$ $$

and

$$ $\displaystyle P(D)$ $\displaystyle=\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a}\}}p({{ \mathbf{x}}}_{0}|\hat{{\mathbf{x}}}_{t}){\mathrm{d}}{\mathbf{x}}_{0}$ (36) $\displaystyle\propto\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a} \}}p({\mathbf{x}}_{0})p({\mathbf{x}}_{t}^{a}|{\mathbf{x}}_{0}){\mathrm{d}}{ \mathbf{x}}_{0}$ $\displaystyle\propto\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a} \}}\exp\left(-\frac{\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}} _{0}\|^{2}}{2(1-\bar{\alpha}_{t})}\right)p({\mathbf{x}}_{0}){\mathrm{d}}{ \mathbf{x}}_{0},$ $$

where the ${\mathbb{D}}_{a}$ represents the set of adversarial examples.
Subtract Eq. 35 by Eq. 36, and we have

$$ $\displaystyle P(B)-P(D)\propto$ $\displaystyle\int\mathbbm{1}_{\{{\mathbf{x}}_{0}\notin{\mathbb{D}}_{a}\}}p({ \mathbf{x}}_{0})$ (37) $\displaystyle\left[\exp\left(-\frac{\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_ {t}}{\mathbf{x}}_{0}-(\sqrt{\bar{\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a }\|_{2}^{2}}{2(1-\bar{\alpha}_{t})}\right)-\exp\left(-\frac{\|{\mathbf{x}}_{t} ^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}\|_{2}^{2}}{2(1-\bar{\alpha}_{t})} \right)\right]{\mathrm{d}}{\mathbf{x}}_{0}.$ $$

Therefore, we only need to compare $\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}-(\sqrt{\bar{
\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a}\|_{2}^{2}$ and $\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}\|_{2}^{2}$ for comparing $P(B)$ and $P(D)$.

Since ${\mathbf{x}}_{t}^{a}=\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{
\alpha}_{t}}{\boldsymbol{\epsilon}}$ and ${\mathbf{x}}_{0}^{a}={\mathbf{x}}_{0}+{\boldsymbol{\epsilon}}_{a}$,

$$ $\displaystyle\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}-( \sqrt{\bar{\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a}\|$ $\displaystyle=\|\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}-( \sqrt{\bar{\alpha}_{t}}-k_{t}){\boldsymbol{\epsilon}}_{a}\|$ (38) $\displaystyle=\|\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}+k_{t}{ \boldsymbol{\epsilon}}_{a}\|,$ $$

$$ $\displaystyle\|{\mathbf{x}}_{t}^{a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}\|$ $\displaystyle=\|\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}^{a}+\sqrt{1-\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}\|$ (39) $\displaystyle=\|\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}+\sqrt{\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}_{a}\|.$ $$

Since $0<k_{t}<\sqrt{\bar{\alpha}_{t}}$ always holds, thus in expectation we have:

$$ $\mathbb{E}_{{\boldsymbol{\epsilon}}}\|\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{ \epsilon}}+k_{t}{\boldsymbol{\epsilon}}_{a}\|<\mathbb{E}_{{\boldsymbol{ \epsilon}}}\|\sqrt{1-\bar{\alpha}_{t}}{\boldsymbol{\epsilon}}+\sqrt{\bar{ \alpha}_{t}}{\boldsymbol{\epsilon}}_{a}\|.$ (40) $$

Hence,

$$ $\mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\exp\left(-\frac{\|{\mathbf{x}}_{t}^ {a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}-(\sqrt{\bar{\alpha}_{t}}-k_{t}){ \boldsymbol{\epsilon}}_{a}\|_{2}^{2}}{2(1-\bar{\alpha}_{t})}\right)\right]> \mathbb{E}_{{\boldsymbol{\epsilon}}}\left[\exp\left(-\frac{\|{\mathbf{x}}_{t}^ {a}-\sqrt{\bar{\alpha}_{t}}{\mathbf{x}}_{0}\|_{2}^{2}}{2(1-\bar{\alpha}_{t})} \right)\right],$ (41) $$

implying that the probability of ADBM reversing the adversarial example to the clean example is higher than that of DiffPure.
∎

###### Theorem 2 .

###### Proof.

## Appendix C Additional Settings

### C.1 Additional Training Settings of ADBM

We implemented ADBM based loosely on the original implementations by Song et al. []. Note that when fine-tuning the ADBM with the pre-trained checkpoint, following Song et al. [], we also adopted the continuous version of Eq. 9. This version is conceptually similar to its discrete counterpart, with the exception that $t$ in Eq. 9 represents a continuous value rather than a discrete one. Moreover, we used the Adam optimizer [] and incorporated the exponential moving average of models, with the average rate being 0.999. The batch size was set to 128 for SVHN and CIFAR-10, 112 for Tiny-ImageNet, and 64 for ImageNet-100 (due to memory constraints). All experiments were run using PyTorch 1.12.1 and CUDA 11.3 on 4 NVIDIA 3090 GPUs.

### C.2 Additional Adaptive Attack Configurations

When performing the adaptive attacks (PGD with EOT) for the AP methods, we set the step sizes to be 0.007, 0.5, and 0.005 for $l_{\infty}$, $l_{1}$, and $l_{2}$ attacks, respectively. For the $l_{1}$ attack, we set the sparsity level as 0.95. As shown in Sec. 3, the adaptive evaluating is quite time-consuming. Thus following Nie et al. [], we conducted the adaptive attacks three times on a subset of
512 randomly sampled images from the test dataset and reported the mean accuracy along with the standard deviation. We note that sometimes the standard deviation is omitted to present the results more clearly.

**Table A2: Accuracies ($\%$) of DiffPure under PGD and AutoAttack using the full gradient on CIFAR-10.**
| Attack Method | Clean Acc | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ norm | $l_{1}$ norm | $l_{2}$ norm | Average |  |  |
| PGD + EOT (Full Grad.) | $92.5\pm 0.5$ | $42.2\pm 2.1$ | $44.3\pm 1.3$ | $60.8\pm 2.3$ | $49.1\pm 1.7$ |
| AutoAttack + EOT (Full Grad.) | $62.70$ | $53.91$ | $63.87$ | $60.16$ |  |

**Table A3: Accuracies ($\%$) of DiffPure and ADBM under different attacks in the $l_{2}$ setting using the full gradient on CIFAR-10. The strongest attack results for each defense method are highlighted.**
| Method | C&W + EOT | DeepFool + EOT | AutoAttack + EOT | PGD + EOT (Our Setting) |
| --- | --- | --- | --- | --- |
| DiffPure | $74.8$ | $78.3$ | $63.9$ | 60.8 |
| ADBM (Ours) | $78.3$ | $84.8$ | $66.8$ | 63.3 |

## Appendix D Additional Evaluation Results

### D.1 Comparison between Different Attack Methods on CIFAR-10

Similar to Lee and Kim [], we first performed a comparison between PGD with 20 EOT samples (full gradient) and AutoAttack with the same number of EOT samples (the default setting of rand version AutoAttack yet with full gradient). The main difference between AutoAttack and vanilla PGD lies in the automatic adjustment of step size by AutoAttack, but the adjustment algorithm may be influenced by the randomness of stochastic pre-processing defense.
The comparison results are presented in Tab. A2. PGD with EOT achieved significantly better attack performance across all threat models.

We additionally performed extra attack evaluation with the full-gradient C&W [] and DeepFool [] attacks, which are optimization-based attacks that differ significantly from PGD. Here their original $l_{2}$ setting [, ] were evaluated with 1,000 iteration steps and 20 EOT samples. The implementation used the standard torchattacks benchmark(^3^33[https://github.com/Harry24k/adversarial-attacks-pytorch](https://github.com/Harry24k/adversarial-attacks-pytorch)). The robustness results are shown in Tab. A3 (along with the PGD and AutoAttack $l_{2}$ results in Tab. A2). We can see that PGD with EOT is also significantly stronger than other attacks such as C&W and DeepFool, which need considerably more iteration steps. Additionally, ADBM is more robust than DiffPure regardless of the evaluation methods.

Thus, considering that AutoAttack is widely recognized as a reliable attack method for AT models, we employed AutoAttack for AT evaluation. Conversely, for AP evaluation, we measured the worst-case robustness of each defense method by employing PGD with EOT in our main experiments.

**Table A4: Accuracies (%) of methods under different white-box adaptive attack threats on SVHN. The same conventions are used as in Tab. 3.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ norm | $l_{1}$ norm | $l_{2}$ norm | Average |  |  |  |  |
| WRN-28-10 | Vanilla | - | $98.11$ | $0.19$ | $0.02$ | $0.03$ | $0.08$ |
| WRN-28-10 | [] | AT | $94.46$ | $52.65$ | $0.16$ | $6.76$ | $19.86$ |
| WRN-28-10 | [] | $93.00$ | $52.70$ | $0.04$ | $3.27$ | $18.67$ |  |
| WRN-28-10 | [] | $95.56$ | 64.00 | $0.14$ | $5.07$ | $23.07$ |  |
| UNet+WRN-28-10 | DiffPure [] | AP | $93.9\pm 0.7$ | $39.7\pm 2.2$ | $46.1\pm 2.1$ | $63.3\pm 0.8$ | $49.7\pm 1.7$ |
| UNet+WRN-28-10 | ADBM (Ours) | $93.5\pm 0.8$ | $47.9\pm 1.4$ | $\textbf{51.2}\pm 0.6$ | $\textbf{65.7}\pm 1.5$ | $\textbf{54.9}\pm 1.1$ |  |

**Table A5: Accuracies (%) of methods under different adaptive attack threats on Tiny-ImageNet. The same conventions are used as in Tab. 3.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ norm | $l_{1}$ norm | $l_{2}$ norm | Average |  |  |  |  |
| WRN-28-10 | Vanilla | - | $69.49$ | $0.06$ | $2.09$ | $0.08$ | $0.74$ |
| WRN-28-10 | [] | AT | $50.94$ | $29.13$ | $20.15$ | $24.54$ | $24.61$ |
| WRN-28-10 | [] | $50.89$ | $27.02$ | $17.79$ | $23.29$ | $22.70$ |  |
| WRN-28-10 | [] | $57.59$ | 38.41 | $10.73$ | $27.21$ | $25.45$ |  |
| UNet+WRN-28-10 | DiffPure [] | AP | $58.0\pm 1.7$ | $24.8\pm 1.8$ | $44.3\pm 0.3$ | $32.9\pm 1.1$ | $34.0\pm 0.8$ |
| UNet+WRN-28-10 | ADBM (Ours) | $59.6\pm 1.2$ | $29.3\pm 1.7$ | $\textbf{46.0}\pm 0.4$ | $\textbf{38.1}\pm 1.3$ | $\textbf{37.8}\pm 0.9$ |  |

**Table A6: Accuracies (%) of methods under different adaptive attack threats on ImageNet-100. The same conventions are used as in Tab. 3.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ norm | $l_{1}$ norm | $l_{2}$ norm | Average |  |  |  |  |
| ResNet-50 | [] | AT | $78.8$ | $47.2$ | $3.6$ | $25.0$ | $25.3$ |
| ResNet-50 | [] | $79.5$ | 50.3 | $3.9$ | $23.8$ | $26.0$ |  |
| UNet+ResNet-50 | DiffPure [] | AP | $77.3$ | $22.2$ | $55.5$ | $58.4$ | $45.4$ |
| UNet+ResNet-50 | ADBM (Ours) | $79.5$ | $25.2$ | 58.6 | 61.3 | 48.4 |  |

### D.2 Additional White-Box Results on Several Datasets

The accuracies on SVHN are shown in Tab. A4. ADBM consistently achieved significantly better adversarial robustness than DiffPure across all adversarial threats. On average, ADBM outperformed DiffPure by 5.2%. In addition, although SOTA AT models showed excellent performance on seen attacks, they struggle to exhibit robustness against unseen $l_{1}$ and $l_{2}$ attacks. On average, ADBM surpasses these AT models by 31.8%.

The white-box adaptive evaluation results on Tiny-ImageNet are respectively presented in Tab. A5 and Tab. A6. In the Tiny-ImageNet evaluation, we maintained consistent settings with those used for CIFAR-10, with the exception that for the $l_{\infty}$ threat, we set the bound to be $\epsilon_{\infty}=4/255$, which is a popular setting for this dataset [, ]. In the ImageNet-100 evaluation, we set the bounds $\epsilon_{\infty}=4/255$, $\epsilon_{1}=75$, $\epsilon_{2}=2$, which is a commonly used setting for the high-resolution datasets like ImageNet-1K. For this dataset, we directly compared ADBM with representative ResNet-50 AT checkpoints specified trained on ImageNet-1K by masking out the 900 output channels not included in ImageNet-100. By examining Tab. A5 and Tab. A6, we can draw similar conclusions to those observed on SVHN and CIFAR-10.

### D.3 Additional Black-Box Results on CIFAR-10

The black-box evaluation results on CIFAR-10 are presented in Tab. A7. In this evaluation, we maintained consistent settings with those used for SVHN. By examining Tab. 4 and Tab. A7, we can conclude that under the realistic black-box attacks, ADBM has advantages over AT models even on the seen threat.

**Table A7: Accuracies ($\%$) of methods under three query-based attacks and the transfer-based attack on CIFAR-10. The same conventions are used as in Tab. 4.**
| Architecture | Method | Type | Clean Acc | Robust Acc |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| RayS | Square | SPSA | Transfer | Average |  |  |  |  |
| WRN-70-16 | Vanilla | - | $97.02$ | $6.64$ | $2.44$ | $1.37$ | - | - |
| WRN-70-16 | [] | AT | $91.10$ | $79.20$ | $71.62$ | $80.76$ | $89.98$ | $82.33$ |
| WRN-70-16 | [] | $88.54$ | $73.91$ | $69.35$ | $75.82$ | $87.64$ | $79.05$ |  |
| WRN-70-16 | [] | $88.74$ | $78.81$ | $73.93$ | $79.88$ | $87.89$ | $81.85$ |  |
| WRN-70-16 | [] | $93.25$ | $81.89$ | $76.30$ | $82.13$ | $90.34$ | $84.78$ |  |
| UNet+WRN-70-16 | [] | AP | $87.93$ | $74.22$ | $72.17$ | $68.55$ | $84.28$ | $77.43$ |
| UNet+WRN-70-16 | DiffPure [] | $92.51$ | $90.92$ | $90.53$ | $90.33$ | $90.16$ | $90.89$ |  |
| UNet+WRN-70-16 | ADBM (Ours) | $91.86$ | 91.31 | 91.50 | 90.72 | 90.39 | 91.16 |  |

### D.4 Results of ADBM on New Classifiers

Here we utilized the fine-tuned ADBM checkpoint, trained with adversarial noise from a WRN-70-16 classifier, as the pre-processor for a WRN-28-10 model and a vision transformer (ViT) model(^4^44We used the checkpoint released by [https://github.com/dqj5182/vit_cnn_cifar_10_from_scratch](https://github.com/dqj5182/vit_cnn_cifar_10_from_scratch), which had 90.6% clean accuracy on CIFAR-10.) directly, denoted as ADBM(Transfer). The results shown in Tab. A8 demonstrate that ADBM(Transfer) achieved robustness levels comparable to ADBM trained directly with WRN-28-10 or the ViT (52.9% vs. 53.1% on WRN-28-10, and 43.2% vs. 45.1% on ViT). This finding highlights the practicality of ADBM, as the fine-tuned ADBM model on a specific classifier can potentially be directly applied to a new classifier without requiring retraining. We guess this may be attributed to the transferability of adversarial noise [].

**Table A8: Accuracies (%) of different methods on CIFAR-10. Here the classifier used a WRN-28-10 or a vision transformer. ADBM(Transfer) was trained with noise from a WRN-70-16 while ADBM(Direct) was trained with noise from the WRN-28-10 or the vision transformer directly.**
| Method | Classifier | $l_{\infty}$ | $l_{1}$ | $l_{2}$ | Average |
| --- | --- | --- | --- | --- | --- |
| DiffPure | WRN-28-10 | $42.4$ | $60.3$ | $43.8$ | $48.8$ |
| ADBM(Transfer) | $45.1$ | $61.7$ | 52.0 | $52.9$ |  |
| ADBM(Direct) | 45.3 | 62.1 | $51.9$ | 53.1 |  |
| DiffPure | ViT | $25.0$ | $41.8$ | $51.6$ | $39.5$ |
| ADBM(Transfer) | $28.9$ | $46.7$ | $54.1$ | $43.2$ |  |
| ADBM(Direct) | 30.9 | 48.4 | 56.1 | 45.1 |  |

### D.5 Inference Cost of ADBM

Taking CIFAR-10 as an example, the classifier WRN-70-16 consists of 267M parameters and has an inference cost of 39 GFlops. On the other hand, the UNet architecture, specifically the DDPM++ continuous used in this work, consists of 104M parameters and has an inference cost of 18 GFlops. Therefore, although ADBM has demonstrated effectiveness even with a single reverse step (Tab. 2), the computational cost still increases by 46.2% in this case. It remains an open question whether the scale of the UNet architecture, which is currently directly adapted from architectures designed for generative tasks, can be further reduced for adversarial purification. We leave it to future work.

## Appendix E Boarder Impact

Our method, which effectively purifies adversarial noise, can potentially hinder the utility of certain “adversarial for good” methods. For example, it could cause more difficult copyright protection using adversarial noise [] when abusing our method. In addition, there seems to be a trade-off between adversarial robustness and the risk of privacy leakage []. But in general, we believe the concrete positive impacts on trustworthy machine learning outweigh the potential negative impacts.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: please see weaknesses
soundness: 2
strengths: - Introduces a comprehensive training process to adapt the diffusion model for adversarial purification tasks.
- Theoretically and empirically demonstrates superior performance compared to DiffPure.
summary: This paper trains a purifier based on the theoretical framework of a diffusion model, making it better suited for adversarial purification tasks.
weaknesses: - Unlike DiffPure, the Adversarial Diffusion Model (ADBM) requires reasoning about adversarial perturbations for purification, which may **limit its generalizability to unseen attacks**, similar to challenges faced by adversarial training. For instance, the experimental results in Table 3—beyond different settings of white-box attacks, how does it perform against Square attacks or StAdv?
- The author mentions the Robust Diffusion Classifier (RDC) method in the paper but **does not compare it with the purification component of RDC, namely Likelihood Maximization (LM)**. To my knowledge, RDC’s LM can handle unseen attacks better than ADBM without needing adversarial perturbation training.
- In the original diffusion model framework, as the time step approaches infinity, $x_T$ converges to a standard Gaussian distribution. With ADBM losing this property, there may need to be corresponding adjustments in the selection of variables such as $\bar{\alpha}$.

---

confidence: 5
contribution: 2
initial_rating: 3
presentation: 3
questions: 1. What is the performance on more datasets with more classification numbers?

2. What is the performance of the proposed method with various networks?

3. What is the performance of the proposed method towards different types of attack?
soundness: 2
strengths: The proposed ADBM has the complete theoretical support, and the experiments on the CIFAR10 demonstrate the effectiveness of the proposed method on some chosen datasets.
summary: This paper proposes a new method for Diffusion-based Purification, which is named as Adversarial Diffusion Bridge Model (ADBM). Different from previous methods, ADBM directly constructs a reverse bridge from the diffused adversarial data back to its original clean examples. Experiments show the effectiveness of the proposed method.
weaknesses: 1. The proposed method is only verified on the datasets with small classification number, such as CIFAR10 and SVHN. The experiments on datasets with small sizes can not fully demonstrate the effects of the proposed strategy, since the applications in the real world will have large number of classification number. A more suitable dataset could be ImageNet with at least 1K class number. I think the complicated data distribution will largely influence the performance of diffusion models.

2. The experimental results are mainly built with the network of WRN, and the experimental results with more types of networks are not shown.

3. Compared with other methods, the accuracy on the adversarial examples are not improved a lot, while the accuracy on the clean examples are decreased clearly. The authors should analyze the factor which limits the accuracy on the clean examples.

---

confidence: 4
contribution: 3
initial_rating: 8
presentation: 2
questions: 1. Does ADBM only work for the DDIM sampler? The motivation for this question is that the assumption for the proofs is the DDIM sampler. What happens if we change the DDIM sampler to the original DDPM sampler?

To sum up, there are two main contributions for ADBM: 1) proposed a full-gradient adaptive attack method. 2) proposed an interesting AT paradigm to enhance AP based on the unconditional diffusion model. All my concerns are listed in Weaknesses and Questions. Considering 1) the lacking the necessary baseline and attack method and 2) the writing problem, I rate it as "marginally above the acceptance threshold." If the author could solve these concerns, I'm willing to increase my rate.
soundness: 3
strengths: 1. This paper proposed a new adaptive pipeline based on the diffusion model's full gradient, which can further ensure the diffusion-based AP's robustness. The robustness of the diffusion-based AP is always questionable since it is a computation cost to get the full gradient of the diffusion model. Previous works proposed various gradient estimation methods, such as the adjoint method from DiffPure and the surrogate process from Lee. et al. [1], which remains a question: Is the improvement of such diffusion-based AP due to the estimation error of the gradient? Lee. et al. also prove this question. This paper is the first work to evaluate the robustness of diffusion-based AP by the full gradient to the best of my knowledge. I think this will benefit further study of diffusion-based AP.

2. The AT paradigm for diffusion-based AP proposed in this paper is novel and robust. To establish the loss function for AT, this paper chooses to connect the adversarial samples and the generation target $x_{0}$, which is interesting. Then, the detailed proofs verify that the loss function could ensure the removal of the adversarial perturbation after various times of the reverse process.

3. The experimental results show that ADBM achieves the SOTA performance. Specifically, the experiment also includes unseen attacks to illustrate how the proposed AT paradigm could work on unseen threats.  

[1] Minjong Lee and Dongwoo Kim. Robust evaluation of diffusion-based adversarial purification. In Int. Conf.
Comput. Vis. (ICCV), 2023
summary: Adversarial attack is a challenge for the neural network. This paper proposed a diffusion model-based adversarial purification (AP) to defend against adversarial attacks via adversarial training (AT) called ADBM. ADBM alleviates the trade-off between noise purification efficiency and recovery quality by proposing a new loss function to fine-tune the diffusion model via the AT paradigm. ADBM also offers detailed proofs to ensure the adversarial perturbation will be gradually removed. The experimental results show that ADBM achieves the SOTA performance.
weaknesses: 1. The writing for this paper should be improved. 1) Some math symbols are confused. For example $\hat{x}\_0$. It first indicated in 299 lines that $\hat{x}\_0$ should be the final point of the reverse process, thus having $\hat{x}\_0=x\_{0}$. But, in 879 lines, $\hat{x}\_0$ changed to the prediction of $x_{0}$ for $x_{t}$, thus causing the confusion. There are various similar mistakes, such as $x_{t}^{d}$ in 265 lines.  2) One-step DDIM is confusing since this paper includes the discrete and continuous VP-SDE. Setting $s=1$ is truly the one-step DDIM based on the discrete VP-SDE but is not one-step for continuous VP-SDE since the time sequence of continuous VP-SDE is in $[0.0, 1.0]$. In this condition, $s=1$ means the entire reverse process for continuous VP-SDE instead of the one-step. The authors should explicitly clarify which formulation (discrete or continuous) they use when discussing one-step DDIM and explain the implications for both cases.

2. The experimental results may not be enough. 1) The BPDA [1] should be considered to test the performance of the ADBM since it is a special attack designed for the AP.  Adding additional experiments on CIFAR-10 against BPDA ($\ell_{\infty}$,$\epsilon = 8/255$) will further strength the contribution. 2) AToP should be considered as the baseline, even if only making an ablation study on CIFAR-10 since ADBM is similar to AToP. The only difference is that AToP may be suitable for any generative model, and ADBM is for the diffusion model only.  Adding additional experiments on CIFAR-10 against PGD+EOT ($\ell_{\infty}$,$\epsilon = 8/255$, EOT=20, steps=200) to compare the performance of ADBM and AToP (the generative model chooses GAN, which is the best reported in AToP) will enhance the contribution for this paper. Additionally, adding an ablation study between ADBM and AToP (the generative model chooses VP-SDE) against PGD+EOT ($\ell_{\infty}$,$\epsilon = 8/255$, EOT=20, steps=200) will further show the validity of ADBM.

[1] Minjong Lee and Dongwoo Kim. Robust evaluation of diffusion-based adversarial purification. In Int. Conf.
Comput. Vis. (ICCV), 2023

Meta-review: This paper makes several contributions to the field: 1) Propose the full gradient evaluation for diffusion models based on AP. 2) Propose an AT-based paradigm to enhance diffusion models based-AP, where the author offers detailed proofs to show that AT could finally cancel the adversarial perturbation term hidden on the adversarial samples. 3) The author reports detailed experiments, including unseen attacks, to prove the validity and efficiency of the proposed method. Although the proposed method might introduce additional training cost to diffusion model-based AP, its overall contribution is enough.

Decision: Accept (Poster)