google/edward2

A simple probabilistic programming language.

What it solves

Edward2 is a simple probabilistic programming language (PPL) designed to integrate seamlessly with deep learning ecosystems. It allows researchers and developers to define probabilistic models as Python functions (programs) and provides tools to manipulate these models for flexible training and inference, such as calculating log-joint probabilities or performing posterior predictions.

How it works

The library uses RandomVariables to define the structure of a probabilistic model. These variables carry probability distributions and can interoperate with standard tensor operations. Models are expressed as Python functions that instantiate these random variables to represent a generative process.

To enable flexible inference, Edward2 employs a mechanism called tracing. A tracer can intercept the instantiation of random variables within a model function, allowing the user to replace priors with posterior means or transform the model into a different representation (e.g., converting a generative program into a log-joint probability function for use in MCMC algorithms).

Who it’s for

It is primarily intended for AI researchers and practitioners who need to operate with probabilistic models and uncertainty modeling within deep learning frameworks.

Highlights

  • Multi-backend support: Works with TensorFlow (default), JAX, and NumPy.
  • Tracing mechanism: Allows for dynamic manipulation of model computation without changing the model code.
  • Program transformations: Includes built-in tools like make_log_joint_fn to convert generative models into probability functions.
  • Deep learning integration: Designed to work with TensorFlow Distributions and other tensor-based operations.