GradDiv: Adversarial Robustness of Randomized Neural Networks via Gradient Diversity Regularization

Sungyoon Lee, Hoki Kim, Jaewook Lee

TL;DR

Randomized neural networks often fail against adaptive attacks because their internal gradients are too similar, allowing attackers to use a "proxy" average gradient to break the defense. This paper introduces GradDiv, a regularization technique that forces these internal gradients to scatter, effectively "confusing" the attacker and significantly boosting adversarial robustness across multiple benchmarks.

What Problem Does This Paper Address?

Deep learning models are notoriously fragile: a tiny, invisible-to-humans change to an image (an adversarial perturbation) can cause a state-of-the-art network to misclassify a "stop sign" as a "speed limit sign."

One popular defense is to use Randomized Neural Networks (RNNs). Instead of one fixed model, an RNN effectively uses a slightly different network for every single prediction. The idea is that if an attacker doesn't know exactly which "version" of the network will be used, they can't calculate the precise gradient needed to create a successful attack.

However, attackers found a workaround called Expectation over Transformation (EOT). By averaging the gradients of many possible versions of the randomized network, they create a "proxy gradient" that is often "good enough" to fool the system. The authors of this paper identified the root cause: in standard RNNs, the gradients of different randomized samples are still highly aligned. If all the "versions" of your network want to move in the same direction to increase error, the average direction is a perfect roadmap for an attacker.

Methods

The authors propose Gradient Diversity (GradDiv) regularization to solve this alignment problem. The goal is to make the gradients of different randomized samples as diverse (scattered) as possible.

Fig. 1. Illustration of the proposed Gradient Diversity (GradDiv) regularization. GradDiv encourages a randomized neural network to have dispersed loss gradients. The xy-plane is spanned by the sample mean vectors u (black line) and ureg (red line) of the sample gradients for Baseline (black dots) and Baseline+GradDiv (red dots), respectively. The length of sample mean vector is called the Mean Resultant Length (MRL). The z-axis is chosen to be orthogonal to both u and ureg.

They introduced three specific mathematical ways to enforce this diversity during training:

  1. $R_\kappa$ (vMF Concentration): They model the gradient directions using a von Mises-Fisher distribution and penalize the concentration parameter ($\kappa$). Lower concentration means more spread-out directions.
  2. $R_{mean}$ (Cosine Similarity): A straightforward approach that penalizes the average cosine similarity between pairs of gradient samples.
  3. $R_{DPP}$ (Determinantal Point Process): A more sophisticated method that treats gradients as points in a subset and uses DPPs to encourage diversity, effectively trying to make the gradient vectors orthogonal to one another.

By adding these terms to the standard training loss, the network learns to maintain high accuracy while ensuring its internal "opinions" on how to handle an input are as varied as possible.

Datasets

The researchers evaluated GradDiv on three standard computer vision benchmarks:

  • MNIST: Handwritten digits (the "Hello World" of computer vision).
  • CIFAR10: 60,000 small color images in 10 classes (e.g., airplanes, dogs, trucks).
  • STL10: A dataset designed for developing unsupervised feature learning, featuring higher-resolution images than CIFAR10.

Key Insights and Ideas

  • The MRL Bound: The authors mathematically proved that the potential damage an attacker can do using a proxy gradient is upper-bounded by the Mean Resultant Length (MRL) of the gradients. By minimizing MRL, you are literally shrinking the maximum possible "loss increase" an attacker can achieve.
  • Alignment is the Enemy: As shown in Figure 2, as the angle ($\theta$) between the attacker's proxy gradient and the true gradient increases, the attack's effectiveness plummets. GradDiv is designed to maximize this angle for as many samples as possible.
Fig. 2. The effectiveness of the PGD attack using proxy gradients instead of the actual gradients. The proxy gradients are obtained by rotating the true gradients by θ with a random axis at every iterations of the attack. The loss difference caused by the proxy gradients (red) decreases, and the accuracy under the PGD attack (blue) increases as θ increases to 90◦. Note that the graph of the loss difference (red) appears similar to the cosine curve, empirically demonstrating (11).
  • Diverse Decision Boundaries: Beyond just gradients, GradDiv forces the different randomized versions of the network to have different "decision boundaries." This means an adversarial example that fools one version is much less likely to fool another.

Key Results

GradDiv consistently outperformed baseline randomized defenses (like Adv-BNN) across various attack types (FGSM, PGD, EOT-PGD, etc.):

  • Robustness Boost: On CIFAR10, GradDiv improved overall robust accuracy from 42.95% to 45.77% against a suite of combined attacks.
  • Resistance to EOT: On MNIST, GradDiv maintained high accuracy (~92%) even at high perturbation levels ($\epsilon=0.4$) where the baseline Adv-BNN dropped significantly (~85%).
  • Reduced Transferability: The "transferability" (how well an attack on one sample model works on another) dropped dramatically. In one test, the accuracy of a transfer attack went from 24% (very successful attack) to 75% (mostly failed attack) after applying GradDiv.
  • No Obfuscation: The authors verified that their defense doesn't rely on "obfuscated gradients" (a common flaw in many defenses that gives a false sense of security), passing the standard checklist for robust evaluation.
Fig. 4. Top: The scatter plot of the gradient samples on the unit circle. The dots indicate the gradient samples from the randomized neural network and the lines indicate the sample mean vectors of the gradients with the length of the sample MRL ˆρ (black: Adv-BNN, red: Adv-BNN+GradDiv). Bottom: The density plots of the loss increase under the EOT-PGD attack. GradDiv effectively reduces the effects of the proxy-gradient-based attack as indicated in (12).

Limitations and Future Work

  • Computational Cost: Calculating multiple gradients for every training step (to compute the diversity loss) increases the time and memory required for training.
  • Empirical Nature: Like all adversarial defense research, these results are empirical. While GradDiv stands up to current state-of-the-art attacks, the "arms race" continues, and future adaptive attacks might find new ways to circumvent gradient diversity.
  • Generalization: The paper primarily tests GradDiv on top of Bayesian Neural Networks (Adv-BNN). Exploring how it interacts with other types of randomization (like input transformations) remains an open area for research.

Summary updated

BibTeX
@article{lee2023graddiv,
  author = {Sungyoon Lee and Hoki Kim and Jaewook Lee},
  title = {{GradDiv: Adversarial Robustness of Randomized Neural Networks via Gradient Diversity Regularization}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2023},
  doi = {10.1109/tpami.2022.3169217},
}
Figure