[Paper Review] Bayesian Layers: A Module for Neural Network Uncertainty
Introduces Bayesian Layers, a drop-in extension to neural network libraries that enables distributions over weights, activations, functions, and stochastic outputs, supporting scalable uncertainty-aware models and probabilistic programming integration.
We describe Bayesian Layers, a module designed for fast experimentation with neural network uncertainty. It extends neural network libraries with drop-in replacements for common layers. This enables composition via a unified abstraction over deterministic and stochastic functions and allows for scalability via the underlying system. These layers capture uncertainty over weights (Bayesian neural nets), pre-activation units (dropout), activations ("stochastic output layers"), or the function itself (Gaussian processes). They can also be reversible to propagate uncertainty from input to output. We include code examples for common architectures such as Bayesian LSTMs, deep GPs, and flow-based models. As demonstration, we fit a 5-billion parameter "Bayesian Transformer" on 512 TPUv2 cores for uncertainty in machine translation and a Bayesian dynamics model for model-based planning. Finally, we show how Bayesian Layers can be used within the Edward2 probabilistic programming language for probabilistic programs with stochastic processes.
Motivation & Objective
- Motivate the need for uncertainty-aware functions in large-scale neural networks.
- Describe a drop-in, modular extension that adds distributions over weights, activations, and entire functions as layers.
- Enable scalable experimentation by preserving standard layer semantics and composability.
- Demonstrate practical deployments including Bayesian Transformers and Bayesian dynamics for planning.
- Show integration with the Edward2 probabilistic programming language for flexible inference.
Proposed method
- Extend neural network layers to support distributions over states (weights, pre-activations, activations, or the function itself).
- Represent distributions using Edward RandomVariables and support sampling, log_prob, and KL regularizers.
- Provide drop-in Bayesian variants of common layers (e.g., VariationalDense) that preserve standard constructor signatures.
- Incorporate Gaussian Process layers and stochastic output layers to model function uncertainty and likelihoods.
- Introduce reversible (flow-based) and probabilistic-programming compatible layers for broader uncertainty propagation.
- Demonstrate model-scale experiments including a 5-billion parameter Bayesian Transformer and a Bayesian dynamics model for planning.
Experimental results
Research questions
- RQ1How can uncertainty be incorporated into standard neural network layers without changing the existing modeling workflow?
- RQ2Can a modular layer-centric framework support Bayesian neural nets, Gaussian processes, and flow-based models at scale?
- RQ3What practical architectural demonstrations (e.g., Bayesian Transformer, Bayesian PlaNet) illustrate the utility of Bayesian Layers?
- RQ4How can Bayesian Layers integrate with probabilistic programming languages like Edward2 for flexible inference?
- RQ5What are the trade-offs and challenges in scaling and inference when using distributions over functions across architectures?
Key findings
- Bayesian Layers enable uncertainty-aware models by providing drop-in replacements for common layers with distributions over weights, activations, or the function itself.
- The framework supports Bayesian neural nets, stochastic activations, Gaussian processes, and reversible layers within existing neural network workflows.
- A 5-billion-parameter Bayesian Transformer was trained with 512 TPUv2 cores, showing scalability and uncertainty estimation in machine translation.
- A Bayesian dynamics model for model-based planning (Bayesian PlaNet) achieves comparable task performance while revealing non-trivial weight posteriors.
- Bayesian Layers can be used as primitives within Edward2 for probabilistic programming of stochastic processes.
- Experiments demonstrate model parallelism and scalable inference enabling new model classes and uncertainty-aware applications.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.