Sample-specific Noise Injection for Diffusion-based Adversarial Purification

Yuhao Sun, Jiacheng Zhang, Zesheng Ye, Chaowei Xiao, Feng Liu

Introduction

Deep Neural Networks (DNNs) are notoriously vulnerable to adversarial attacks—imperceptible perturbations designed to trigger misclassification. Diffusion-Based Purification (DBP) has emerged as a leading defense strategy, utilizing the generative capabilities of diffusion models to "wash away" adversarial noise. The process involves a forward step, where Gaussian noise is added to the input, followed by a reverse step to reconstruct a clean image.

However, traditional DBP methods rely on a fixed noise level ($t^*$) for all samples. This "one-size-fits-all" approach creates a fundamental trade-off: a low $t^*$ may fail to remove adversarial perturbations, while a high $t^*$ can destroy the semantic features of clean images, leading to a significant drop in standard accuracy. This paper introduces Sample-specific Score-aware Noise Injection (SSNI), a framework that adaptively determines the optimal noise level for each individual image, effectively balancing robustness and clean accuracy.

The SSNI Framework

SSNI is designed to be a flexible wrapper for existing DBP methods, such as DiffPure or GDMP. The core innovation lies in using the "score norm" as a proxy for the level of adversarial contamination in a sample.

1. Measuring Deviation via Score Norms

In diffusion models, the score function ($\nabla_x \log p_t(x)$) points toward high-density regions of the clean data distribution. The magnitude of this score—the score norm—indicates how far a data point has strayed from the clean manifold. The authors observed a consistent correlation: higher adversarial perturbation leads to higher score norms.

2. Expected Perturbation Score (EPS)

To avoid the circular dependency of needing a noise level to calculate a score, the authors propose the Expected Perturbation Score (EPS). This metric aggregates scores across a spectrum of noise levels, providing a robust measurement of an image's "adversarialness" before the final purification level is set.

3. Adaptive Reweighting

Once the EPS is calculated, SSNI applies a reweighting function—either a simple linear mapping or a non-linear sigmoid function—to translate the score into a sample-specific $t^*$. This ensures that heavily perturbed images receive more noise for thorough cleaning, while relatively clean images receive minimal noise to preserve their original features.

Experimental Evaluation

The framework was evaluated on the CIFAR-10 and ImageNet-1K benchmarks against a suite of sophisticated attacks, including PGD+EOT, AutoAttack, and the diffusion-specific DiffAttack.

Key Findings

  • Improved Accuracy Trade-offs: On CIFAR-10, integrating SSNI into the DiffPure baseline improved clean accuracy by 3.58% without sacrificing adversarial robustness.
  • Scalability to ImageNet: On the high-resolution ImageNet-1K dataset, SSNI simultaneously improved both clean accuracy (by ~2.5%) and robust accuracy (by ~1.0%).
  • Resistance to Adaptive Attacks: SSNI remains effective even when the attacker is aware of the defense mechanism (white-box adaptive attacks), proving that the sample-specific nature of the defense is difficult to bypass.
  • Semantic Preservation: Qualitative analysis shows that SSNI-purified images retain significantly more original detail than fixed-noise methods, which often suffer from "semantic drift" (e.g., a bird being reconstructed as a different animal due to excessive noise).

Theoretical Insights

Mathematically, the authors demonstrate that SSNI expands the "purification range." By allowing $t^*$ to vary, the model can access purified states that are unreachable by any single fixed-noise level. This flexibility allows the defense to adapt to varying attack strengths within the same dataset.

Limitations and Future Directions

While SSNI offers a significant leap in performance, it introduces a small amount of computational overhead (typically 0.5s to 5s of latency depending on the hardware). Additionally, the reweighting functions are currently manually designed; future research could explore automated methods to "learn" the optimal mapping between score norms and noise levels.

Conclusion

Sample-Specific Noise Injection (SSNI) represents a shift from static to adaptive adversarial defense. By leveraging the internal logic of diffusion models—the score norm—SSNI provides a smarter, more nuanced way to purify images, ensuring that protection does not come at the cost of image utility.

Summary updated

BibTeX
@inproceedings{sun2025sample,
  author = {Yuhao Sun and Jiacheng Zhang and Zesheng Ye and Chaowei Xiao and Feng Liu},
  title = {{Sample-specific Noise Injection for Diffusion-based Adversarial Purification}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=6nbcwJVZNy},
}
Figure