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.
The Quantization Paradox
Neural network quantization—reducing the precision of weights and activations to low-bit values (e.g., 1-bit binary)—is a standard approach for deploying models on memory-constrained edge devices. Interestingly, researchers have observed that these Binary Neural Networks (BNNs) often appear significantly more robust against standard gradient-based adversarial attacks, such as PGD or FGSM, than their full-precision counterparts. This has led to claims that quantization acts as a natural defense mechanism.
This paper investigates whether this robustness is real or an artifact of gradient masking. Because quantized networks use discrete, step-like functions, the gradients used by attackers to craft adversarial examples often become zero or uninformative. The attacker's optimization fails not because the model is secure, but because the mathematical signal guiding the attack is broken.
Unmasking "Fake" Robustness
A classic sign of gradient masking is when a "black-box" attack (which doesn't rely on the model's gradients) is more successful than a "white-box" attack. The authors confirmed this phenomenon in BNNs, proving that the perceived security was merely an illusion caused by vanishing gradients.
Restoring Signal via Temperature Scaling
To restore signal propagation without altering the model's actual predictions, the authors propose a remarkably simple modification: temperature scaling. By applying a single scalar value ($\beta$) to the network's final output logits before the softmax cross-entropy loss, the gradient landscape is reshaped while the decision boundary remains unchanged.
The authors introduced two mathematically grounded methods to choose the optimal $\beta$:
- Network Jacobian Scaling (NJS): Sets $\beta$ based on the inverse of the mean singular values of the input-output Jacobian, ensuring the error signal flows backward without vanishing.
- Hessian Norm Scaling (HNS): Finds a $\beta$ that maximizes the Frobenius norm of the loss Hessian, ensuring the gradient is highly sensitive to input changes.
Key Results
The modified attacks, dubbed PGD++ and FGSM++, were tested on CIFAR-10 and CIFAR-100 across multiple architectures. The results were definitive: the "robustness" of BNNs was completely bypassed.
As shown in the data, standard PGD attacks on weight-quantized BNNs often resulted in adversarial accuracies between 17% and 47%. The proposed PGD++ (NJS/HNS) dropped this accuracy to 0.00% across ResNet, VGG, and DenseNet architectures. Furthermore, these temperature-scaled attacks outperformed standard versions even on adversarially trained, full-precision networks, suggesting that poor signal propagation is a broader bottleneck in evaluating neural network robustness.
Conclusion
This work demonstrates that quantized networks offer no inherent security against gradient-based attacks. The perceived robustness is a result of gradient masking, which can be easily bypassed using temperature scaling. The authors encourage the research community to incorporate signal propagation checks into all future adversarial robustness evaluations to ensure that reported defenses are genuine and not merely artifacts of broken gradient flow.
Summary updated