Adversarial Defenses Via Vector Quantization

Zhiyi Dong, Yongyi Mao

Abstract

Deep Neural Networks (DNNs) are notoriously vulnerable to adversarial examples—small, calculated perturbations that lead to misclassification. This paper introduces a novel preprocessing defense that replaces simple pixel-level discretization with Vector Quantization (VQ). By treating images as collections of patches rather than independent pixels, the proposed methods, patched RandDisc (pRD) and sliding-window RandDisc (swRD), achieve state-of-the-art robustness across multiple benchmarks without requiring expensive model retraining.

Introduction

The fragility of DNNs against adversarial attacks remains a critical barrier to their deployment in safety-critical applications. While adversarial training is a common countermeasure, its high computational cost makes it difficult to scale. Preprocessing-based defenses offer a more efficient alternative by cleaning input images before they reach the classifier. However, existing methods like RandDisc (scalar quantization) often ignore the spatial dependencies between pixels, leading to suboptimal denoising and leaving models vulnerable to sophisticated attacks.

Methodology: From Pixels to Patches

The core contribution of this work is the application of Rate-Distortion Theory to adversarial defense. The authors argue that an optimal compressor should exploit multi-dimensional dependencies rather than treating every pixel as an island.

The preprocessing framework maps an input image X to a quantized version X-hat before classification by model f.

The authors propose two primary algorithms:

  1. patched RandDisc (pRD): Images are partitioned into $s \times s$ non-overlapping patches. Each patch is mapped to its nearest neighbor in a learned codebook of representative patches. This "patch-level" approach captures local structures like edges and textures more effectively than pixel-level rounding.
  2. sliding-window RandDisc (swRD): This method improves upon pRD by using overlapping patches. A pixel's final value is determined by a weighted average of all quantized patches covering its location, resulting in smoother reconstructions and higher visual fidelity.

Both methods incorporate randomized Gaussian noise during the process, which allows the authors to provide certified robustness—a mathematical guarantee that the model's prediction remains stable within a specific perturbation radius.

Experimental Results

The proposed defenses were evaluated on MNIST, CIFAR-10, CIFAR-100, and ImageNet. The results demonstrate a significant performance leap over traditional scalar quantization methods.

Visual comparison of denoising quality across different methods.

On CIFAR-10, swRD achieved a robust accuracy of 73.67% under the rigorous AutoAttack benchmark, compared to just 13.92% for the previous state-of-the-art RandDisc. On ImageNet, the method reached 67.50% robust accuracy, outperforming several complex adversarial training-based models. Qualitatively, as seen in the figure above, swRD acts as a superior denoiser, restoring images with much higher visual fidelity than the blocky results produced by scalar quantization.

Conclusion

By shifting the focus from individual pixels to local patches, Vector Quantization provides a robust "plug-and-play" shield for existing DNNs. While there is a minor trade-off in natural accuracy due to the lossy nature of quantization, the massive gains in adversarial robustness and the ability to protect pre-trained models without retraining make pRD and swRD highly practical solutions for securing deep learning systems.

Summary updated

BibTeX
@inproceedings{dong2023adversarial,
  author = {Zhiyi Dong and Yongyi Mao},
  title = {{Adversarial Defenses Via Vector Quantization}},
  booktitle = {Neurocomputing},
  year = {2023},
}
Figure