TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

TensorFlow Probability

TensorFlow Probability is a library for probabilistic reasoning and statistical analysis in TensorFlow. As part of the TensorFlow ecosystem, TensorFlow Probability provides integration of probabilistic methods with deep networks, gradient-based inference using automatic differentiation, and scalability to large datasets and models with hardware acceleration (GPUs) and distributed computation.

To get started with TensorFlow Probability, see the install guide and view the Python notebook tutorials.


Our probabilistic machine learning tools are structured as follows:

Layer 0: TensorFlow

Numerical operations—in particular, the LinearOperator class—enables matrix-free implementations that can exploit a particular structure (diagonal, low-rank, etc.) for efficient computation. It is built and maintained by the TensorFlow Probability team and is part of tf.linalg in core TensorFlow.

Layer 1: Statistical Building Blocks

Layer 2: Model Building

  • Edward2 (tfp.edward2): A probabilistic programming language for specifying flexible probabilistic models as programs.
  • Probabilistic layers (tfp.layers): Neural network layers with uncertainty over the functions they represent, extending TensorFlow layers.
  • Trainable distributions (tfp.trainable_distributions): Probability distributions parameterized by a single tensor, making it easy to build neural nets that output probability distributions.

Layer 3: Probabilistic Inference

  • Markov chain Monte Carlo (tfp.mcmc): Algorithms for approximating integrals via sampling. Includes Hamiltonian Monte Carlo, random-walk Metropolis-Hastings, and the ability to build custom transition kernels.
  • Variational Inference ( Algorithms for approximating integrals through optimization.
  • Optimizers (tfp.optimizer): Stochastic optimization methods, extending TensorFlow Optimizers. Includes Stochastic Gradient Langevin Dynamics.
  • Monte Carlo (tfp.monte_carlo): Tools for computing Monte Carlo expectations.

TensorFlow Probability is under active development and interfaces may change.


In addition to the Python notebook tutorials listed in the navigation, there are some example scripts available:

Report issues

Report bugs or feature requests using the TensorFlow Probability issue tracker.