Protecting Neural Networks with Hierarchical Random Switching: Towards Better Robustness-Accuracy Trade-off for Stochastic Defenses

Xiao Wang, Siyue Wang, Pin-Yu Chen, Yanzhi Wang, Brian Kulis, Xue Lin, Peter Chin

Here is a blog-style summary of the paper.

TL;DR

This paper introduces Hierarchical Random Switching (HRS), a novel stochastic defense mechanism that protects deep neural networks from adversarial attacks by dynamically switching between parallel network channels at runtime. To fairly evaluate the cost of such defenses, the authors also propose the Defense Efficiency Score (DES), demonstrating that HRS achieves a robustness-accuracy trade-off that is up to 5× more efficient than existing stochastic defenses.

What Problem Does This Paper Address?

Deep neural networks (DNNs) are notoriously vulnerable to adversarial attacks—small, calculated perturbations to inputs that cause models to misclassify images or even allow attackers to "reprogram" the network for a different task.

To counter this, researchers developed stochastic defenses (like defensive dropout or adding Gaussian noise). These methods introduce randomness into the network structure during inference to obfuscate gradients, making it incredibly difficult for an attacker to calculate an effective adversarial perturbation.

However, current stochastic defenses suffer from a massive drawback: they severely degrade the model's accuracy on clean, legitimate data. Hardening the network typically means tanking its real-world performance. Furthermore, there hasn't been a standardized way to quantify this trade-off. This paper addresses both challenges by introducing a metric to evaluate the trade-off and a new architecture that minimizes accuracy drop while maximizing defense.

Methods

The authors tackle the problem with a two-pronged approach:

  1. Defense Efficiency Score (DES): A new metric designed to quantify the robustness-accuracy trade-off. It is calculated as: $$\text{DES} = \frac{\Delta d}{\Delta t}$$ where $\Delta d$ is the gain in the defense rate (percentage of failed attacks) and $\Delta t$ is the corresponding drop in clean test accuracy. A higher DES means a more efficient defense.

  2. Hierarchical Random Switching (HRS): Instead of randomly dropping neurons or injecting disruptive noise, HRS divides a base neural network into several sequential blocks. Each block is replaced with a "switching block" containing a set of parallel channels. Each channel shares the same architecture but contains different weights.

Figure 3: Illustration of HRS-protected model.

At runtime, a random switcher activates only one channel per block for any given forward pass. Because the active path changes constantly, the network's structure is a moving target.

To ensure every possible path is fully functional (preventing accuracy drops), they use a bottom-up training algorithm. They train the channels of the first block to convergence and freeze them. Then, they train the second block's channels while randomly switching the first block, forcing the upper layers to adapt to the variations of the lower layers.

Datasets

The authors evaluated their approach using two standard computer vision benchmarks:

  • MNIST
  • CIFAR-10

Key Insights and Ideas

  • Decentralized Randomization: Traditional stochastic defenses like Dropout or Gaussian noise derive all variations from a single, centralized base model. Attackers can exploit this by creating a "surrogate" model to bypass the defense. HRS is entirely decentralized; no single path has privilege over another, eliminating the centralized vulnerability.
  • Complex Gradient Distributions: Standard defenses yield a clean, unimodal input gradient distribution when attacked. As shown in Figure 1, HRS shatters this uniformity, creating a highly unpredictable gradient landscape that thwarts gradient-based optimization attacks.
Figure 1: An example of input gradient distribution of stochastic defense models on a randomly selected dimension. We sample the input gradient of each defense for 200 times at the first step of CW- PGD attack. While SAP, dropout and Gaussian noise all yield a unimodal distribution, this trend is less obvious for HRS.
  • Resilience to Adaptive Attacks: Surprisingly, when attackers attempted a "fixed-randomness" adaptive attack (disabling the randomness scheme to find a vulnerability), HRS actually performed better (lower attack success rate) than under standard white-box attacks. This highlights the strength of its decentralized architecture.

Key Results

  • Superior Trade-off Efficiency: On the CIFAR-10 dataset under PGD attacks, HRS achieved a mean DES of 35.43, vastly outperforming adversarial training (7.37), Gaussian noise injection (6.18), and defensive dropout (0.81).
Figure 2: Defense efficiency of different defenses under PGD attack on CIFAR-10. See Appendix C.5 for implementation details. The solid lines are fitted by linear regression.
  • High Robustness, Low Accuracy Drop: Under strong PGD and CW-PGD attacks ($\epsilon = 8/255$), HRS limited the attack success rate to ~51.1% and 54.5% while suffering less than a 0.48% drop in clean test accuracy. Under the same conditions, other stochastic defenses were completely broken (100% attack success rate).
  • Defeating Adversarial Reprogramming: HRS provides the first effective defense against adversarial reprogramming, successfully preventing attackers from stealthily repurposing a CIFAR-10 model to classify MNIST images.

Limitations and Future Work

While the bottom-up training approach scales linearly with the number of blocks, training multiple parallel channels still incurs a higher initial computational training cost than a standard deterministic network. Additionally, while HRS significantly mitigates the accuracy drop, scaling up the defense strength (adding more blocks or channels) still results in a minor, predictable trade-off slope. Future work could explore optimizing channel selection or weight-sharing strategies to reduce the training footprint.

Summary updated

Abstract

Despite achieving remarkable success in various domains, recent studies have uncovered the vulnerability of deep neural networks to adversarial perturbations, creating concerns on model generalizability and new threats such as prediction-evasive misclassification or stealthy reprogramming. Among different defense proposals, stochastic network defenses such as random neuron activation pruning or random perturbation to layer inputs are shown to be promising for attack mitigation. However, one critical drawback of current defenses is that the robustness enhancement is at the cost of noticeable performance degradation on legitimate data, e.g., large drop in test accuracy. This paper is motivated by pursuing for a better trade-off between adversarial robustness and test accuracy for stochastic network defenses. We propose Defense Efficiency Score (DES), a comprehensive metric that measures the gain in unsuccessful attack attempts at the cost of drop in test accuracy of any defense. To achieve a better DES, we propose hierarchical random switching (HRS), which protects neural networks through a novel randomization scheme. A HRS-protected model contains several blocks of randomly switching channels to prevent adversaries from exploiting fixed model structures and parameters for their malicious purposes. Extensive experiments show that HRS is superior in defending against state-of-the-art white-box and adaptive adversarial misclassification attacks. We also demonstrate the effectiveness of HRS in defending adversarial reprogramming, which is the first defense against adversarial programs. Moreover, in most settings the average DES of HRS is at least 5X higher than current stochastic network defenses, validating its significantly improved robustness-accuracy trade-off.
BibTeX
@inproceedings{wang2019protecting,
  author = {Xiao Wang and Siyue Wang and Pin-Yu Chen and Yanzhi Wang and Brian Kulis and Xue Lin and Peter Chin},
  title = {{Protecting Neural Networks with Hierarchical Random Switching: Towards Better Robustness-Accuracy Trade-off for Stochastic Defenses}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.24963/ijcai.2019/833},
}
Figure