On the Robustness of Bayesian Neural Networks to Adversarial Attacks

Luca Bortolussi, Ginevra Carbone, Luca Laurenti, Andrea Patanè, Guido Sanguinetti, Matthew Wicker

TL;DR

This paper provides a theoretical explanation for why Bayesian Neural Networks (BNNs) are more robust to adversarial attacks than their deterministic counterparts. By analyzing BNNs in the "infinitely-wide" limit, they prove that the expected gradient of the loss with respect to inputs vanishes, making them inherently resistant to gradient-based attacks, even when individual network samples are vulnerable.

What Problem Does This Paper Address?

Deep learning models, particularly neural networks (NNs), are highly susceptible to adversarial attacks. These are subtle, often imperceptible, perturbations to input data that can cause models to misclassify inputs catastrophically. This vulnerability is a major roadblock for deploying NNs in safety-critical applications like autonomous driving. While Bayesian Neural Networks (BNNs) have shown empirical promise in resisting these attacks, the underlying theoretical reasons for this robustness have remained unclear. This paper aims to bridge that gap by providing a theoretical framework for understanding BNN robustness.

Methods

The core of the paper's theoretical contribution lies in analyzing the behavior of BNNs in the over-parameterized limit, specifically when the number of neurons in the network layers approaches infinity. This limit allows them to leverage the well-understood properties of Gaussian Processes (GPs), as infinitely-wide NNs are known to converge to GPs.

Key theoretical steps include:

  • Geometric Analysis of Data Manifolds: They show that adversarial attacks exploit "degeneracies" in the data distribution, where data points lie on a lower-dimensional submanifold within the higher-dimensional ambient space.
  • Symmetry Property of NNs: They prove that for any NN achieving zero loss, there exists another NN with the same architecture and loss but with an opposite orthogonal gradient to the data manifold.
  • Convergence to GPs: By relying on the established convergence of infinitely-wide BNNs to GPs, they demonstrate that the expected gradient of the loss with respect to the BNN posterior distribution vanishes when projected onto directions orthogonal to the data manifold. This vanishing expected gradient is the key to their theoretical robustness.
  • Empirical Validation: They validate their theoretical findings using BNNs trained with Hamiltonian Monte Carlo (HMC) and Variational Inference (VI) on various datasets.

Datasets

  • MNIST: A widely used dataset of handwritten digits.
  • Fashion MNIST: A dataset of clothing items, serving as a more challenging image classification task.
  • Synthetic dataset: A custom dataset used for regression tasks to analyze the data manifold properties.

Key Insights and Ideas

  • Adversarial Attacks Exploit Data Geometry: The paper solidifies the intuition that adversarial vulnerabilities are deeply tied to the underlying structure of the data, specifically when data resides on lower-dimensional manifolds.
  • BNN Posterior Averaging is Key: The robustness of BNNs doesn't come from individual network samples being robust, but from the averaging over the posterior distribution of weights. This averaging effectively cancels out the adversarial gradients.
  • Infinitely-Wide BNNs are Provably Robust: In the theoretical limit of infinite width, BNNs are shown to be provably immune to gradient-based adversarial attacks, provided certain mild assumptions about the data manifold and the GP kernel are met.
  • Accuracy and Robustness Can Coexist in BNNs: Contrary to deterministic NNs where a trade-off often exists, BNNs, especially those trained with HMC, show a positive correlation between accuracy and robustness.

Key Results

  • Theoretical Proof of Robustness: The paper provides a mathematical proof that in the infinitely-wide limit, BNN posteriors are robust to gradient-based adversarial attacks.
  • Empirical Validation of Gradient Vanishing: Experiments show that as more samples are drawn from the BNN posterior, the magnitude of the expected gradients decreases significantly.
  • Improved Robustness Against Attacks: BNNs (especially HMC-trained ones) consistently outperform deterministic NNs against FGSM, PGD, and CW gradient-based attacks, and also show increased robustness against gradient-free attacks (ZOO).
  • Accuracy-Robustness Correlation: For BNNs trained with HMC, higher accuracy correlates with higher robustness, a reversal of the typical trade-off seen in deterministic NNs.

Limitations and Future Work

  • Theoretical Limit vs. Finite Width: The theoretical guarantees are for the infinitely-wide limit. While empirical results suggest benefits in finite-width networks, the exact guarantees do not directly translate.
  • Bayesian Inference Challenges: Performing exact Bayesian inference is computationally expensive. The paper notes that while approximate methods like VI offer some robustness, they may not achieve the same level as more accurate methods like HMC.
  • Focus on Gradient-Based Attacks: The theoretical results primarily address gradient-based attacks. While empirical results show improved robustness against gradient-free attacks, this is not theoretically proven.
  • Future Work: The authors suggest renewed interest in efficient Bayesian inference algorithms, which could unlock the full potential of BNNs for robust and accurate AI. They also highlight the need to explore how approximate inference methods can be improved to better capture the robustness properties observed with exact Bayesian inference.

Summary updated

BibTeX
@article{bortolussi2024robustness,
  author = {Luca Bortolussi and Ginevra Carbone and Luca Laurenti and Andrea Patanè and Guido Sanguinetti and Matthew Wicker},
  title = {{On the Robustness of Bayesian Neural Networks to Adversarial Attacks}},
  journal = {IEEE Transactions on Neural Networks and Learning Systems},
  year = {2024},
  doi = {10.1109/tnnls.2024.3386642},
}
Figure