Unifying Gradients to Improve Real-world Robustness for Deep Networks

Yingwen Wu, Sizhe Chen, Kun Fang, Xiaolin Huang

Abstract

The wide application of deep neural networks (DNNs) demands an increasing amount of attention to their real-world robustness, particularly against score-based query attacks (SQAs). SQAs are highly threatening because they require only black-box access to model outputs to estimate gradients and craft adversarial perturbations. Defending against these attacks while maintaining model utility for legitimate users is a significant challenge. We propose Unifying Gradients (UniG), a real-world defense that unifies gradients across different inputs toward a weaker, universal direction. By misleading attackers into following less effective universal attack trajectories, UniG enhances robustness without compromising clean accuracy. Implemented as a computationally efficient Hadamard product module, UniG is a plug-and-play solution for any pre-trained model. Extensive experiments on CIFAR10 and ImageNet demonstrate that UniG significantly outperforms existing baselines in both robustness and output stability.

Introduction

Deep neural networks (DNNs) have achieved remarkable success across various domains but remain vulnerable to adversarial attacks. In real-world scenarios, attackers often lack access to the model's internal parameters, relying instead on score-based query attacks (SQAs). By querying the model and observing changes in output probabilities, attackers can estimate gradients and generate effective adversarial examples.

Current defenses typically fall into two categories: Adversarial Training (AT), which often suffers from a significant drop in accuracy on clean data, and Randomness Injection (RI), which can lead to unstable outputs that degrade user experience. There is a critical need for a defense that provides strong robustness against SQAs while preserving the model's original performance and output characteristics. UniG addresses this by strategically "polluting" the gradient information leaked through scores, leading attackers away from the true vulnerable directions of the model.

Methodology: Unifying Gradients (UniG)

The core innovation of UniG lies in treating the gradient as an information leak that can be manipulated. In a typical SQA, the attacker uses queries to reconstruct the gradient. UniG modifies the network function such that the perceived gradient is approximately constant across different inputs in a batch. This constant direction is chosen to be a Universal Attack Perturbation (UAP), which research has shown to be significantly less effective than sample-specific perturbations.

UniG is implemented as a lightweight Hadamard product module ($A$) inserted into the penultimate layer of a pre-trained network. During inference, this module is optimized for a single iteration on each incoming batch to minimize two objectives:

  1. Gradient Unification Loss: Reduces the variance between gradients of different inputs, pushing them toward the UAP direction.
  2. Forward Consistency Loss: Ensures that the modified model's outputs remain close to the original outputs, preserving clean accuracy and logit stability.
Method flowchart and robustness comparison

Because it only modifies a small module at the end of the network, UniG can be added to any pre-trained model without retraining the entire backbone. This dynamic adjustment allows the model to adapt to the specific inputs it receives, ensuring that the "unified" gradient is always misleading for the current batch.

Experimental Results

UniG was evaluated on CIFAR10 and ImageNet datasets using architectures such as PreResNet18 and WideResNet-50-2. The defense was tested against five different SQAs and compared with four baseline defenses.

As shown in the robustness comparison, UniG achieves superior performance compared to Adversarial Training (AT) and Randomness Injection (RI). On CIFAR10, under a 2500-query Square attack, UniG maintained 77.80% accuracy, significantly higher than the 67.34% achieved by the state-of-the-art AT model. Crucially, UniG maintained a clean accuracy of 94.26%, identical to the undefended vanilla model, whereas AT models typically drop to around 87%.

Optimization loss and margin loss over query iterations

Furthermore, UniG exhibits exceptional logit stability. The modification to model outputs (measured by LogitDiff) is minimal, ensuring that the confidence scores provided to users remain reliable and consistent. The effectiveness of UniG is further illustrated by the margin loss over query iterations. While attackers can quickly reduce the margin loss of vanilla and RI-defended models, UniG keeps the margin loss high, effectively stalling the attack progress. The optimization process for the UniG module is also highly efficient, converging rapidly within a few steps.

Conclusion

Unifying Gradients (UniG) offers a novel and effective approach to real-world DNN defense. By strategically misleading attackers toward weaker universal gradients, it provides state-of-the-art robustness against score-based query attacks without the typical accuracy-robustness trade-off. Its plug-and-play nature and computational efficiency make it highly suitable for practical deployment. Future work may explore more advanced "instructional" directions to further enhance the misdirection capabilities of the defense.

Source: Wu et al., "Unifying Gradients to Improve Real-World Robustness for Deep Networks," ACM Trans. Intell. Syst. Technol., 2023.

Summary updated

Abstract

The wide application of deep neural networks (DNNs) demands an increasing amount of attention to their real-world robustness, i.e., whether a DNN resists black-box adversarial attacks, among them score-based query attacks (SQAs) are the most threatening ones because of their practicalities and effectiveness: the attackers only need dozens of queries on model outputs to seriously hurt a victim network. Defending against SQAs requires a slight but artful variation of outputs due to the service purpose for users, who share the same output information with attackers. In this paper, we propose a real-world defense, called Unifying Gradients (UniG), to unify gradients of different data so that attackers could only probe a much weaker attack direction that is similar for different samples. Since such universal attack perturbations have been validated as less aggressive than the input-specific perturbations, UniG protects real-world DNNs by indicating attackers a twisted and less informative attack direction. To enhance UniG's practical significance in real-world applications, we implement it as a Hadamard product module that is computationally-efficient and readily plugged into any model. According to extensive experiments on 5 SQAs and 4 defense baselines, UniG significantly improves real-world robustness without hurting clean accuracy on CIFAR10 and ImageNet. For instance, UniG maintains a CIFAR-10 model of 77.80% accuracy under 2500-query Square attack while the state-of-the-art adversarially-trained model only has 67.34% on CIFAR10. Simultaneously, UniG greatly surpasses all compared baselines in clean accuracy and the modification degree of outputs. The code would be released.
BibTeX
@article{wu2023unifying,
  author = {Yingwen Wu and Sizhe Chen and Kun Fang and Xiaolin Huang},
  title = {{Unifying Gradients to Improve Real-world Robustness for Deep Networks}},
  journal = {ACM Trans. Intell. Syst. Technol.},
  year = {2023},
  doi = {10.1145/3617895},
}
Figure