Bayesian Inference with Anchored Ensembles of Neural Networks, and Application to Reinforcement Learning

Tim Pearce, Nicolas Anastassacos, Mohamed Zaki, Andy NeelyarXiv 2018

Abstract

The use of ensembles of neural networks (NNs) for the quantification of predictive uncertainty is widespread. However, the current justification is intuitive rather than analytical. This work proposes one minor modification to the normal ensembling methodology, which we prove allows the ensemble to perform Bayesian inference, hence converging to the corresponding Gaussian Process as both the total number of NNs, and the size of each, tend to infinity. This working paper provides early-stage results in a reinforcement learning setting, analysing the practicality of the technique for an ensemble of small, finite number. Using the uncertainty estimates produced by anchored ensembles to govern the exploration-exploitation process results in steadier, more stable learning.

Introduction

Standard neural networks are deterministic, providing point estimates that lack a measure of predictive uncertainty. This overconfidence is a significant hurdle in safety-critical domains like medicine or autonomous driving. While Bayesian Neural Networks (BNNs) offer a principled solution, they are often computationally prohibitive. Practitioners frequently turn to ensembles—training multiple models from different initializations—to estimate uncertainty via predictive variance. However, this approach lacks a rigorous analytical foundation. Without proper regularization, ensemble members often collapse toward a single solution, underestimating uncertainty. Existing approximations like MC Dropout often fail to capture complex parameter correlations, leading to poor uncertainty "shapes" compared to gold-standard methods like Gaussian Processes (GPs).

Methodology: Anchored Ensembling

The core contribution of this work is a simple modification to the standard loss function. Traditional L2 regularization (weight decay) pulls weights toward zero:

$$Loss \propto \dots + \lambda ||\theta||^2$$

The authors propose Anchored Ensembling. Instead of regularizing toward zero, each network in the ensemble is regularized toward its own unique, random initial parameters ($\theta_0$):

$$Loss_{anchor} \propto \dots + \lambda ||\theta - \theta_0||^2$$

This "anchoring" trick ensures that the ensemble's distribution of predictions is a consistent estimator of the true Bayesian posterior. The random initialization acts as a "quasi-prior," and the anchoring prevents the training process from washing this prior away. Mathematically, the authors prove that in the limit of infinite width and ensemble size, these anchored ensembles are equivalent to Gaussian Processes.

Experimental Evaluation

Synthetic 1D Regression and Uncertainty Shape

The method was first evaluated on a synthetic 1D regression task to compare uncertainty "bands" against established methods.

Comparison of uncertainty quantification methods on a 1D regression task. Anchored ensembles (far right) produce uncertainty envelopes that closely match the ground truth of HMC and GPs, whereas MC Dropout and Variational Inference (VI) produce less realistic shapes.

As shown in the figure above, anchored ensembles produce uncertainty envelopes that are visually consistent with Hamiltonian Monte Carlo (HMC) and Gaussian Processes. In contrast, MC Dropout and standard Variational Inference (VI) produce significantly narrower or less realistic uncertainty shapes, particularly in regions far from the training data. This confirms that anchoring preserves the diversity of the ensemble, allowing it to maintain high uncertainty in data-sparse regions.

Reinforcement Learning: CartPole

The utility of these uncertainty estimates was tested in a Reinforcement Learning (RL) setting using the CartPole benchmark. By employing Thompson Sampling with anchored ensembles to govern exploration, the agent achieved steadier learning. Unlike standard $\epsilon$-greedy strategies, which often exhibit unstable "sigmoidal" learning curves, the anchored ensemble approach demonstrated a smooth, exponential decay in error. The agent showed "intelligent" uncertainty: low variance in critical states (where precision is vital) and high variance in rare states (signaling a need for more data).

Conclusion

Anchored ensembling provides a computationally efficient bridge between standard neural network ensembles and rigorous Bayesian inference. While the theoretical proof holds strictly for the final layer, empirical results suggest the benefits extend to deep architectures. Future work includes scaling this method to high-dimensional RL environments and investigating the optimal selection of hyperparameters, such as regularization strength and anchoring distributions.

Summary updated

BibTeX
@misc{pearce2018bayesian,
  author = {Tim Pearce and Nicolas Anastassacos and Mohamed Zaki and Andy Neely},
  title = {{Bayesian Inference with Anchored Ensembles of Neural Networks, and Application to Reinforcement Learning}},
  year = {2018},
  eprint = {1805.11324},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.11324},
}
Figure