Improving Bayesian Neural Networks by Adversarial Sampling

Jiaru Zhang, Yang Hua, Tao Song, Hao Wang, Zhengui Xue, Ruhui Ma, Haibing Guan

Introduction

Bayesian Neural Networks (BNNs) offer a theoretically grounded approach to deep learning by treating model weights as probability distributions rather than fixed points. This allows BNNs to quantify uncertainty—effectively "knowing what they don't know." Despite this advantage, BNNs are rarely deployed in industrial production due to a persistent "performance gap": they typically achieve lower accuracy and exhibit less training stability than their deterministic counterparts.

The Challenge of Sampling Randomness

The primary cause of this performance gap is sampling randomness. In a standard BNN, weights are sampled from a distribution (e.g., a Gaussian) during both training and inference. If a "bad" or low-performing set of weights is sampled during training, it introduces significant noise into parameter updates. During testing, the final prediction is an ensemble of these random samples; if the distribution contains "weak links"—samples with poor individual performance—they drag down the overall accuracy of the model.

Adversarial Sampling: Raising the Floor

To address this, the authors propose Adversarial Sampling (AS). Instead of relying on purely random weight samples, AS identifies the "worst-case" samples within the current distribution—those that produce the highest prediction loss—and forces the model to learn from them.

The Mechanism

The technique utilizes the reparameterization trick, where weights are expressed as $w = \mu + \epsilon \cdot \sigma$. In standard BNNs, $\epsilon$ is random noise. In AS, the model performs $N$ steps of iterative updates on $\epsilon$ to maximize loss, creating an internal "adversarial attack" on the model's own weights. The training objective then combines standard prediction loss, this adversarial loss, and a KL-divergence term to maintain the probabilistic nature of the network.

Performance and Stability

One of the most immediate benefits of Adversarial Sampling is the stabilization of the training process. Standard BNNs often show jagged, fluctuating error rates as different samples are drawn. By targeting the most difficult samples, AS smooths these curves and leads to more robust convergence.

Training error rates for BNNs with and without Adversarial Sampling. AS leads to lower error and significantly smoother convergence.

Key Results

The researchers evaluated AS on standard benchmarks including CIFAR-10 and CIFAR-100 using ResNet and VGG architectures. The results demonstrated consistent improvements across the board:

  • Accuracy Gains: On CIFAR-100 with ResNet56, ensemble accuracy rose from 53.21% to 58.63%.
  • Worst-Case Robustness: The accuracy of the single worst weight sample improved dramatically (e.g., from 44.92% to 54.76% on CIFAR-100), effectively "raising the floor" of the model's performance.
  • Uncertainty Preservation: Importantly, AS does not sacrifice the BNN's ability to quantify uncertainty. Models still correctly assigned high uncertainty to out-of-distribution or corrupted data.
Accuracy distributions for ResNet20 (CIFAR-10) and ResNet56 (CIFAR-100). AS (blue) shifts the distribution toward higher accuracy and narrows the variance compared to standard BNNs (orange).

Conclusion

Adversarial Sampling provides a practical solution to the sampling noise that has long hindered Bayesian Neural Networks. By focusing training on the most challenging weight configurations, AS bridges the performance gap with deterministic models while retaining the critical benefits of uncertainty quantification. While the iterative nature of the weight perturbation adds some computational overhead, the gains in reliability and accuracy make it a compelling step toward making BNNs production-ready.

Summary updated

BibTeX
@inproceedings{zhang2022improving,
  author = {Jiaru Zhang and Yang Hua and Tao Song and Hao Wang and Zhengui Xue and Ruhui Ma and Haibing Guan},
  title = {{Improving Bayesian Neural Networks by Adversarial Sampling}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i9.21250},
}
Figure