Abstract
Edward is a flexible probabilistic programming library built on top of TensorFlow that unifies modeling, inference, and model criticism. By leveraging computational graphs, it allows researchers to seamlessly combine deep learning with complex probabilistic models and scale their inference algorithms using GPUs and distributed training.
Introduction
Probabilistic modeling is a powerful way to reason about uncertainty in data, but modern machine learning applications present two major hurdles. First, researchers are increasingly combining traditional statistical models with deep learning (e.g., deep generative models), which requires highly expressive software abstractions. Second, these models are being deployed on massive datasets, requiring scalable computation and hardware acceleration.
While earlier probabilistic programming languages (PPLs) like BUGS or Stan pioneered the field, they often struggle to integrate seamlessly with modern deep learning architectures or scale efficiently to massive, out-of-core datasets. The authors introduce Edward to bridge this gap, providing a high-level Python library that brings the rigor of Bayesian statistics to the scalable, hardware-accelerated ecosystem of TensorFlow.
Methodology: The Iterative Loop
Edward’s design is deeply rooted in statistician George Box’s iterative loop for scientific modeling: Build a model -> Infer hidden structure -> Criticize the fit -> Repeat.
To support this loop, Edward introduces several key software design choices:
- Modeling via Composition: Models are built using a simple language of random variables that act as tensor objects in a TensorFlow computational graph. This allows users to easily compose directed graphical models, Bayesian nonparametrics, and stochastic neural networks (using high-level wrappers like Keras or TF Slim).
- Programmable Inference: Instead of a single "black-box" inference button, Edward treats inference algorithms as programmable classes. It supports Variational Inference (e.g., KLqp, MAP), Monte Carlo (e.g., HMC, SGLD), and Exact inference. Crucially, users can compose inferences—for example, using variational EM by alternating updates between local and global latent variables.
- Data Subsampling: To handle massive datasets, Edward allows inference to be run on subgraphs of the model using mini-batches, making memory and computational complexity independent of the total dataset size.
- Built-in Criticism: Edward provides native functions for point-based evaluations (like classification accuracy or mean squared error) and Posterior Predictive Checks (PPCs), which test how well data generated by the inferred model matches the real-world data.
Evaluation and Results
Because this is a software systems paper, the authors evaluate Edward using simulated toy datasets to demonstrate its API and capabilities. One primary example is the 1D Cosine Dataset, consisting of 50 observations with a cosine relationship and normal noise, used to demonstrate a Bayesian Neural Network.
Key results from the library's demonstration include:
- Bayesian Linear Regression: Edward successfully recovered the "true" simulated weights, with the variational inference algorithm converging in approximately 200 iterations.
- Nonlinear Classification: On a 2D toy dataset, Edward easily demonstrated the limitations of a linear model. Bayesian Logistic Regression achieved only 71% accuracy and failed to separate the classes, while a simple two-layer Bayesian Neural Network written in Edward captured the nonlinear boundary and achieved 81% accuracy.
Discussion and Future Work
Edward’s architecture proves that complex, state-of-the-art algorithms like Expectation Propagation or structured variational auto-encoders don't need bespoke implementations. They can be written in just a few lines of code by composing basic local and global inference objects. By making random variables compatible with standard TensorFlow operations, Edward makes it trivial to parameterize a probability distribution's mean or variance using a deep neural network.
The authors acknowledge a specific limitation in the current implementation of local inferences: Edward currently does not support local inferences within a single random variable object. If a user wants to perform message passing or local inference on different data points, they must represent them as separate random variable objects rather than a single batched variable. Future work involves the continuous community-driven addition of new black-box and model-specific inference algorithms by simply subclassing Edward's base Inference class.
Summary updated