Skip to content

Block Switching: A randomness-based deep learning security defense method

Block Switching: A Stochastic Approach for Deep Learning Security

arXiv· arXiv:2002.07920· Xiao Wang, Siyue Wang, Pin-Yu Chen, Xue Lin, Peter ChinBoston University; Northeastern University; IBM ResearchIndexed by this site · 16 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose the randomization defense Block Switching: with 5 channels, it reduces the CW attack fooling ratio from 100% to 21.0% on MNIST and to 22.2% on CIFAR-10.

Threat modelThe attacker uses FGSM and CW attacks to generate adversarial examples that make the target model predict a target label; the attack uses the gradient of the loss function with respect to the input, and the paper does not explicitly state how much the attacker knows about the model's random mechanism. The victim system is CNN classifiers on MNIST and CIFAR-10.

Questions
Deep neural networks are easily fooled by adversarial examples, and existing defenses are either bypassed by targeted attacks or come at the cost of clean-sample accuracy. The authors aim to design a randomized defense with less harm to test accuracy.
Methods
Proposes Block Switching: train multiple isomorphic sub-models, take their lower layers to form a switching block of parallel channels, attach a randomly initialized common upper layer and train jointly; at inference, randomly activate one channel so that an attacker cannot construct perturbations against a fixed structure.
Experiments and results
Evaluated with FGSM and CW attacks on MNIST and CIFAR-10: 5-channel BS reduces the CW fooling ratio from 100% to 21.0% and 22.2%, respectively, outperforming SAP's 32.1% and 93.3%, with a very small drop in test accuracy; more channels give a stronger defense.
Limitations and future work
The paper does not specifically discuss limitations. The experiments cover only two datasets, MNIST and CIFAR-10, one CNN architecture, and two attacks, FGSM and CW, and do not evaluate adaptive attacks against the randomized defense; the paper does not report the number of test samples used to generate adversarial examples.
Experimental setupBlock Switching (BS) · MNIST、CIFAR-10 · fooling ratio (FR)、L2 distortion et al.
Evaluated models
Block Switching (BS)
Benchmarks
MNISTCIFAR-10
Metrics
fooling ratio (FR)L2 distortiontest accuracy
AI summaryBlock Switching (BS) is a randomness-based defense method against adversarial attacks on deep learning: it replaces one block of layers in the model with multiple parallel channels and randomly activates one of them at runtime, making it unpredictable to attackers. Experiments show that BS has a more dispersed input gradient distribution, outperforms randomized defenses such as stochastic activation pruning (SAP), and has a smaller drop in test accuracy. The method is attack-agnostic and can be used jointly with other defense methods.

Block Switching (BS) is a randomness-based defense method against adversarial attacks on deep learning: it replaces one block of layers in the model with multiple parallel channels and randomly activates one of them at runtime, making it unpredictable to attackers. Experiments show that BS has a more dispersed input gradient distribution, outperforms randomized defenses such as stochastic activation pruning (SAP), and has a smaller drop in test accuracy. The method is attack-agnostic and can be used jointly with other defense methods.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Proposes the randomized defense Block Switching for the adversarial example problem; the authors state that its defense is effective with little loss in test accuracy.

    How to defend against adversarial example attacks while maintaining clean-sample accuracy.

    • Problem setting: Szegedy et al. found that applying perturbations imperceptible to the human eye to the input can cause high-accuracy networks to produce arbitrary incorrect predictions; the authors point out that this would cause serious losses in safety-critical applications such as autonomous driving and image recognition.
    • Shortcomings of existing methods: The authors state that existing defenses (adversarial training, detection, input correction, randomization defenses) have either been shown to be ineffective against attackers' countermeasures or require additional resources; their main trade-off is that the stronger the defense, the worse the test accuracy on clean samples.
    • Core observation: The key to randomization defenses is making the input gradient distribution more dispersed; the authors argue that if gradient directions were uniformly distributed, gradient descent would be no better than a random walk. The authors observe that SAP's gradient distribution is unimodal and concentrated, whereas BS's gradient distribution is multimodal and wider in range (Figure 2).
    • Proposed method: Block Switching (BS) is proposed, which replaces a segment of model layers with multiple parallel channels and randomly activates one channel at runtime, so that attackers cannot exploit the weaknesses of a fixed model structure; it is claimed to have a smaller drop in test accuracy, to be attack-independent, and to be combinable with other defenses (such as adversarial training).
    • Threat model:
      • Attacker goal: Generate adversarial examples that make the target model predict a target label (targeted attack), measured by fooling ratio.
      • Attack methods: FGSM (single-step gradient) and CW attack (optimization-based, which the paper calls the strongest known attack).
      • Attacker knowledge: The attack uses the gradient of the loss function with respect to the input; the paper does not explicitly state whether the attacker knows about the defense's random mechanism, and the experiments generate adversarial examples directly against the defended model following the standard FGSM/CW procedure.
      • Victim system: CNN image classifiers on MNIST and CIFAR-10.
  2. What related research exists?

    Related work covers both attacks and defenses: the attack side includes FGSM, JSMA, and CW, and the defense side includes adversarial training, detection, input correction, and randomization defenses.

    Adversarial attack methods

    • Szegedy et al. (2013) — found that applying small perturbations to the input can make classification networks produce arbitrary incorrect predictions, sparking research on adversarial examples.
    • FGSM (Goodfellow et al., 2015) — uses the gradient direction of the loss function to modify pixels in a single step; a typical one-shot attack.
    • JSMA (Papernot et al., 2016) and CW attack (Carlini & Wagner, 2017) — gradient-based attacks; the paper calls CW the strongest known attack, often used as a benchmark for evaluating model robustness.

    Defense methods

    • Adversarial training (Madry et al., 2017) and detection methods (Grosse et al., 2017; Metzen et al., 2017) — counter adversarial examples through training enhancement and statistical detection, respectively.
    • Input correction (JPEG compression in Das et al., 2017; randomization in Xie et al., 2017) — eliminate or randomize perturbations at the input side.
    • Randomization defenses — SAP (Dhillon et al., 2018) randomly prunes activations; Defensive Dropout (Wang et al., 2018); Hierarchical Random Switching (Wang et al., 2019).

    The paper's criticism of existing defenses and baselines

    • The authors state that these defenses have either been shown to be ineffective against attackers' countermeasures (citing Carlini & Wagner 2017's work bypassing ten detection methods) or require additional resources or cost; the main trade-off is the conflict between defense effectiveness and test accuracy.
    • Baseline methods: SAP (a randomization defense like BS, and the direct comparison target) and the undefended Regular model. Benchmarks: MNIST and CIFAR-10.

    Positioning of this paper: The authors state that BS is attack-independent, has a smaller drop in test accuracy, and can be combined with other defenses (such as adversarial training), distinguishing it from the single defenses above.

  3. How does the paper address this problem?

    BS replaces a segment of network layers with parallel channels, randomly switches channels at runtime, and maintains clean-sample accuracy through two-stage training.

    Overall idea: replace a segment of model layers with a switching block containing multiple parallel channels, randomly activate one channel at runtime, so that the model's behavior changes over time and attackers cannot construct perturbations against a fixed structure; through two-stage training, the common upper layers adapt to each channel, maintaining clean-sample accuracy. The method is named Block Switching (BS).

    Two-stage training and assembly (Figure 1)

    • First stage: Independently train several isomorphic sub-models (same training procedure and data, random weight initialization); the models have similar accuracy and robustness but different parameters.
    • Splitting and assembly: Each sub-model is split into upper and lower parts; all lower parts are merged into the parallel channels of the switching block, and the upper parts are discarded; the switching block is connected to a randomly initialized common upper model.
    • Second stage: The entire BS model is retrained on the same training set so that the common upper layers adapt to the representations of different channels; the authors state that this stage is faster than the first stage because the channels are already trained. In the experiments, MNIST is retrained for 1 epoch and CIFAR-10 for 5 epochs.

    Random switching at inference

    • At runtime, one channel is randomly selected and activated to process the input, while the other channels are inactive, so the model behaves differently at different times.
    • The authors state that only one channel works during inference, so there is no additional computational complexity relative to a regular model; the parallel channels can be stored in a distributed manner and updated periodically.

    Analysis of the defense mechanism

    • Denote the randomized model as Y = Fe(x), where Y is a random variable. The defense manifests in two aspects: the randomness of inference (an adversarial example that succeeds on a model instance sampled at time t1 may fail on an instance sampled at time t2) and the randomness of gradients (the gradient backpropagated to the input is only one sample from the gradient distribution and may not be the optimal descent direction).
    • From the attacker's perspective, the goal is to find the perturbation that maximizes the expected attack success rate, i.e., argmaxx 𝔼[A(Fe(x), T)], where A(·) outputs 1 when the attack succeeds and 0 otherwise, and T is the target class; the meaning is that the attacker needs to generate adversarial examples robust to model variation, rather than targeting only a fixed model instance.
    • The authors argue that a good randomization strategy should make the input gradient distribution wider: in Figure 2, the gradient distribution of the SAP model under CW attack is unimodal and concentrated, while the gradient distribution of BS is multimodal and wider in range (100 samples per distribution). The authors therefore argue that BS is harder to attack than SAP.
    • On accuracy: the authors explain that each channel can work independently, and as long as the common upper layers learn to adapt to the representations of each channel, the model can vary greatly without losing test accuracy; the gradient with respect to the input is random, but the gradient with respect to the model parameters is deterministic (inactive channels have zero gradient), so the second-stage training is not hindered by randomness.

    Evaluation method

    • The metrics are fooling ratio (the proportion of adversarial examples generated by the attack that successfully make the model predict the target label; lower means stronger defense) and the average L2 distortion of the adversarial examples (comparison is fair only at similar distortion levels).
    • Attack settings: on MNIST, FGSM uses ϵ = 0.1 and ϵ = 0.25, and on CIFAR-10, ϵ = 0.01; the CW attack uses 100 iterations of gradient descent with step size 0.1, and the binary search for the constant c in Equation (2) uses 10 iterations.
  4. What experiments did the paper conduct?

    Evaluated on MNIST/CIFAR-10: 5-channel BS reduces the CW fooling ratio to 21.0%/22.2%, outperforming SAP; the more channels, the stronger the defense.

    Experimental Setup

    • Models evaluated: Regular CNN (no-defense baseline), SAP, Block Switching; the average accuracy of the sub-models constituting BS (Sub-models Avg.) is also reported.
    • Architecture: one standard CNN each for MNIST and CIFAR-10 (4 convolutional layers, 2 pooling layers, 2 fully connected layers, with different kernel sizes and layer widths), following the baseline architecture from prior work; trained with SGD, mini batch 128, Dropout regularization.
    • Defense configuration: SAP is added between the first and second fully connected layers, sharing the trained weights with the Regular model; the BS switching block contains 5 channels, each channel composed of the lower layers (all convolutional layers + the first fully connected layer) of 5 independently trained Regular models, with the upper layer (the second fully connected layer) randomly initialized and then retrained as a whole (MNIST 1 epoch, CIFAR-10 5 epochs).
    • Datasets: MNIST and CIFAR-10, with the training set used for training and the test set used for evaluation and generating adversarial examples; the paper does not report the number of test samples used to generate adversarial examples.
    • Attacks and hyperparameters: FGSM (ϵ = 0.1, 0.25 for MNIST; ϵ = 0.01 for CIFAR-10); CW (100 iterations, step size 0.1, binary search over c for 10 steps).
    • Metrics: fooling ratio (FR, lower is better), average L2 distortion of adversarial examples, test accuracy.

    Main Results

    According to Table 2 (MNIST) and Table 3 (CIFAR-10), the fooling ratio (FR) and L2 distortion when the target models are Regular, SAP, and 5-channel BS respectively:

    Swipe horizontally to read the table

    AttackRegular FRSAP FRBS FRBS L2
    MNIST FGSM ϵ=0.13.9%3.7%1.6%2.73
    MNIST FGSM ϵ=0.2534.0%32.8%20.3%6.84
    MNIST CW100.0%32.1%21.0%2.37
    CIFAR-10 FGSM ϵ=0.0125.0%24.8%8.1%0.55
    CIFAR-10 CW100.0%93.3%22.2%0.69
    • The authors state that SAP shows additional robustness relative to Regular, while BS further reduces the fooling ratio; on CIFAR-10 SAP has only a small advantage over Regular.
    • On distortion, the L2 of CW against BS on MNIST is 2.37 (Regular/SAP 2.28), and the L2 of CW against BS on CIFAR-10 is 0.69 (Regular 0.54, SAP 0.52); the authors consider the larger distortion to indicate that the attack algorithm has more difficulty finding adversarial examples within a small neighborhood.

    Clean-Sample Accuracy (Table 1)

    • MNIST: Regular 99.04%, SAP 99.02%, Sub-models Avg. 99.02%, BS 98.95%.
    • CIFAR-10: Regular 78.31%, SAP 78.28%, Sub-models Avg. 78.97%, BS 78.73%.
    • On this basis the authors consider that both SAP and BS maintain test accuracy; direct comparisons are made between Regular and SAP (shared weights) and between the sub-model average and BS.

    Effect of the Number of Channels (Figure 3)

    • What was measured: CW attacks were run on BS models with 1 to 9 channels on MNIST, recording fooling ratio, L2 distortion and test accuracy.
    • Results: the fooling ratio decreases as the number of channels increases, reaching a minimum of 12.1% at 9 channels; the decrease is faster from 1 to 4 channels and slows after 5 channels, and the authors consider the defense benefit from switching to be saturating; distortion increases with the number of channels.
    • Accuracy: test accuracy is nearly flat, decreasing slightly from 78.31% to 78.17% (as stated in the paper's main text; this value is the same as the Regular accuracy on CIFAR-10 in Table 1, and the paper does not separately state the experimental dataset of Figure 3 in the figure caption).

    Other Ablations and Analyses

    • Gradient distribution visualization (Figure 2): under three input images, the CW attack gradient distribution of SAP is unimodal and concentrated, while that of BS is multimodal and wider; each distribution is sampled 100 times. The authors state this explains why BS is harder to attack than SAP.
    • Summary numbers in the abstract and conclusion: the abstract states that 5-channel BS reduces the CW fooling ratio from 100% to 21.0% on MNIST and to 22.2% on CIFAR-10; the conclusion states it can be reduced to 12.1% (corresponding to 9 channels, Figure 3).
    • The paper does not report experiments on adaptive attacks against the randomized defense (such as expected-gradient-type attacks), nor does it report variance across repeated runs.
  5. What are some points that can be further explored?

    The paper does not specifically discuss limitations; the experiments cover only two datasets, one CNN architecture, and two attacks, FGSM and CW.

    Limitations and future directions noted by the authors

    • The paper has no Limitations or Future Work section and does not specifically discuss limitations.
    • In the Conclusion, the authors write that they hope this paper will inspire more work in the direction of "maintaining test accuracy while enhancing model variation" (Conclusion).

    Scope of the experiments

    • The evaluated models are one CNN architecture each on MNIST and CIFAR-10 (4 convolutional layers + 2 pooling layers + 2 fully connected layers), and the defended targets are three types of models: Regular, SAP, and Block Switching (Section 4.1).
    • Attack evaluation includes only two attacks, FGSM and CW, both in the targeted setting; adaptive attacks against the randomization defense are not evaluated (Section 4.2).
    • The channel-count analysis covers CW attacks with 1 to 9 channels (Figure 3); the main experiments use 5 channels (Section 4.1.3).
    • The paper does not report the number of test samples used to generate adversarial examples, the number of experimental repetitions, or the variance.
    • The paper states that BS can be combined with other defenses such as adversarial training, but the experiments do not give results for combined use (Introduction, Conclusion).
  6. Summarize the main content of the paper

    BS defends against adversarial examples by randomly switching parallel channels; with 5 channels, the CW fooling ratio drops to 21.0%/22.2% on MNIST/CIFAR-10.

    A work on adversarial example defense that proposes the randomized defense method Block Switching (BS), aiming to improve a model's resistance to adversarial perturbations without sacrificing clean-sample accuracy.

    • Problem: adversarial perturbations can cause high-accuracy networks to produce arbitrary incorrect predictions; the authors state that existing defenses are either bypassed by targeted counterattacks or come at the cost of test accuracy.
    • Method: independently train multiple isomorphic sub-models, take their lower layers to form a switching block of parallel channels, attach a randomly initialized common upper layer and then train the whole; at inference, randomly activate one channel so that the model structure and input gradients change over time. The authors analyze that BS's input gradient distribution is wider and multimodal compared with SAP (Figure 2), and is therefore harder for gradient attacks to exploit.
    • Main results: on MNIST, 5-channel BS reduces the CW attack fooling ratio from 100.0% for the Regular model to 21.0%, with SAP at 32.1% (Table 2); on CIFAR-10 it reduces it from 100.0% to 22.2%, with SAP at 93.3% (Table 3).
    • Accuracy cost: BS test accuracy is 98.95% on MNIST (Regular 99.04%) and 78.73% on CIFAR-10 (Regular 78.31%) (Table 1).
    • Channel-count effect: on MNIST the CW fooling ratio decreases as the number of channels increases, reaching a minimum of 12.1% at 9 channels, with gains slowing after 5 channels (Figure 3).
    • Authors' conclusion: BS is simple to implement, requires no additional training data or attacker information, adds no extra computation at inference, and can be combined with defenses such as adversarial training; the authors consider that BS shows it is possible to increase model variation while maintaining test accuracy.

Related papers

Show 3 more papers
Read originalarxiv.org