Improved Gradient based Adversarial Attacks for Quantized Networks

Kartik Gupta, Thalaiyasingam Ajanthan

Abstract

Neural network quantization has become increasingly popular due to efficient memory consumption and faster computation resulting from bitwise operations on the quantized networks. Even though they exhibit excellent generalization capabilities, their robustness properties are not well-understood. In this work, we systematically study the robustness of quantized networks against gradient based adversarial attacks and demonstrate that these quantized models suffer from gradient vanishing issues and show a fake sense of robustness. By attributing gradient vanishing to poor forward-backward signal propagation in the trained network, we introduce a simple temperature scaling approach to mitigate this issue while preserving the decision boundary. Despite being a simple modification to existing gradient based adversarial attacks, experiments on multiple image classification datasets with multiple network architectures demonstrate that our temperature scaled attacks obtain near-perfect success rate on quantized networks while outperforming original attacks on adversarially trained models as well as floating-point networks.

Introduction: The Illusion of Robustness

Neural network quantization, particularly Binary Neural Networks (BNNs) where weights and activations are reduced to a single bit, is vital for deploying AI on resource-constrained hardware. Early observations suggested that these quantized models possessed an inherent "natural robustness" to adversarial perturbations. However, this work demonstrates that such robustness is often an artifact of gradient masking—a phenomenon where the discrete nature of the network causes gradients to vanish or become uninformative, effectively hiding the path to adversarial failure from standard white-box attacks.

Comparison of white-box and black-box adversarial accuracy, highlighting gradient masking in BNNs where white-box attacks often fail to outperform black-box ones.

As shown in the figure above, the fact that black-box attacks (which do not rely on the model's gradients) can sometimes achieve higher success rates (lower accuracy) than white-box attacks is a clear indicator of "fake robustness." The challenge lies in extracting informative gradients from these noisy quantized landscapes without altering the model's actual decision boundaries.

Methodology: Temperature Scaling for Signal Propagation

To address gradient vanishing, we propose a post-hoc "temperature scaling" approach. By multiplying the network's logits by a scalar $\beta$ during the backward pass, we can amplify the gradient signal. Since scaling does not change the relative order of the scores, the model's predictions remain identical, preserving the original decision boundary.

We introduce two strategies to determine the optimal scaling factor $\beta$:

  1. Network Jacobian Scaling (NJS): Selects $\beta$ based on the singular values of the input-output Jacobian to achieve "dynamical isometry," ensuring signal flow is neither suppressed nor excessively amplified.
  2. Hessian Norm Scaling (HNS): A hyperparameter-free method that optimizes $\beta$ by maximizing the Frobenius norm of the loss Hessian, identifying the scale where the gradient is most sensitive to input changes.

These techniques are integrated into standard attacks to create FGSM++ and PGD++.

Experimental Results

Evaluations across CIFAR-10, CIFAR-100, and various architectures (ResNet, VGG, DenseNet) reveal that our proposed attacks effectively strip away the perceived robustness of BNNs.

Adversarial accuracy of standard vs. proposed (++) attacks across various architectures, showing near-perfect success rates for PGD++.

As detailed in the table above, while standard PGD ($L_\infty$) might report an adversarial accuracy of 78.01% on a BNN-WAQ VGG-16 model, our PGD++ (NJS) drops that accuracy to a mere 0.01%. Furthermore, these attacks are computationally efficient, adding negligible overhead compared to their standard counterparts, and even show improved performance when attacking standard floating-point and adversarially trained models.

Conclusion

This research highlights that the perceived robustness of quantized networks is largely a failure of gradient-based optimization during attacks. By applying simple temperature scaling, we can restore signal propagation and demonstrate that BNNs are significantly more vulnerable than previously thought. These findings serve as a cautionary tale for evaluating model robustness and encourage the development of defenses that do not rely on gradient masking.

Summary updated

BibTeX
@misc{gupta2020improved,
  author = {Kartik Gupta and Thalaiyasingam Ajanthan},
  title = {{Improved Gradient based Adversarial Attacks for Quantized Networks}},
  year = {2020},
  eprint = {2003.13511},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.13511},
}
Figure