How Sampling Impacts the Robustness of Stochastic Neural Networks

Sina Däubener, Asja Fischer · DOI

Abstract

Stochastic Neural Networks (SNNs) exhibit inherent robustness to adversarial attacks, a phenomenon often attributed to the randomness of their decision boundaries. This paper introduces a unified geometric framework to quantify this robustness, focusing on the misalignment between attack gradients and inference gradients. We demonstrate that while increasing samples during an attack ($S^A$) improves attacker success by reducing gradient variance, increasing samples during inference ($S^I$) does not significantly compromise robustness. Our theoretical findings, validated across multiple benchmarks including FashionMNIST and CIFAR-10, provide a rigorous explanation for the "moving target" advantage of SNNs and offer insights into the design of more resilient stochastic models.

Introduction

Adversarial examples—carefully crafted, imperceptible perturbations designed to mislead models—remain a primary vulnerability in deep learning. In deterministic networks, the decision boundary is static, allowing an attacker to calculate a direct path to misclassification with high precision.

Stochastic Neural Networks (SNNs), such as Bayesian Neural Networks (BNNs) or those employing Monte Carlo (MC) Dropout, offer a potential solution. Because their predictions are based on an ensemble of random model realizations, they present a "moving target" to the attacker. While empirical evidence has long suggested that SNNs are more robust than their deterministic counterparts, a formal theoretical explanation for how sampling parameters and gradient variance influence this robustness has been missing. This paper bridges that gap through a rigorous geometric analysis.

A Geometric Theory of Robustness

The authors propose that robustness in SNNs is fundamentally a matter of geometric misalignment. They analyze the relationship between the perturbation vector (crafted by the attacker) and the gradient of the model realization used during inference.

The Angle Hypothesis

The core of the theory rests on the angle ($\alpha$) between the attack direction and the inference gradient. If this angle is large (approaching 90°), the attack is likely to fail because the perturbation does not move the input toward the specific decision boundary sampled at the moment of inference.

Using the Central Limit Theorem, the authors model these gradients as multivariate Gaussian random variables. This allows them to derive sufficient conditions for robustness in both linear (Theorem 4.1) and "L-smooth" non-linear classifiers (Theorem 4.2). Their analysis shows that robustness is directly proportional to the gradient variance: higher variance leads to larger misalignment angles, creating a natural defensive shield.

The Sampling Paradox

One of the paper's most significant contributions is the clarification of how the number of samples used during different phases of the model's lifecycle impacts security.

  1. Attack Samples ($S^A$): When an attacker uses more samples to craft an exploit, they effectively reduce the gradient variance of their estimate. This allows them to "aim" more accurately, decreasing the misalignment angle and significantly increasing the success rate of the attack. Experiments showed that increasing $S^A$ from 1 to 1000 consistently dropped the accuracy of various SNN architectures.
  2. Inference Samples ($S^I$): Paradoxically, increasing the number of samples used during the actual prediction (inference) does not significantly decrease robustness. The authors prove that while more samples might theoretically lead to a smaller misalignment angle, this effect is mathematically offset by a corresponding decrease in the norm of the gradient estimate.

This finding has major practical implications: it justifies the use of fewer samples at test time, allowing for faster, more computationally efficient inference without sacrificing the model's adversarial defense.

Experimental Validation

The theoretical framework was validated using several standard benchmarks and diverse stochastic architectures:

  • FashionMNIST: Tested using Feedforward Neural Networks (FNNs) trained as Variational Matrix Gaussians (VMG), Infinite Mixtures (IM), and Stochastic Input Networks (SIN).
  • CIFAR-10/100: Tested using Wide ResNets with MC Dropout and Laplace approximations.

The empirical results closely mirrored the theoretical predictions. Specifically, the "robustness conditions" derived in the paper's theorems were shown to be strong predictors of actual adversarial accuracy across different datasets and model types.

Conclusion and Future Work

This research provides a unified explanation for why SNNs resist gradient-based attacks like FGM and PGD. By identifying the geometric "angle" and "margin" as the primary drivers of robustness, the authors explain why existing defenses—such as gradient norm penalization—are effective: they are essentially manipulating these geometric properties.

While the current analysis focuses on gradient-based attacks and assumes a degree of smoothness in the decision boundaries, it sets the stage for future exploration into non-Gaussian gradient distributions and black-box attack scenarios. Ultimately, these geometric insights provide a roadmap for designing the next generation of naturally robust stochastic defense mechanisms.

Summary updated

BibTeX
@inproceedings{daubener2022how,
  author = {Sina Däubener and Asja Fischer},
  title = {{How Sampling Impacts the Robustness of Stochastic Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=VrCA2ccga4},
}
Figure