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.
Components
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
- Distributions
(
tfp.distributions
): A large collection of probability distributions and related statistics with batch and broadcasting semantics. - Bijectors
(
tfp.bijectors
): Reversible and composable transformations of random variables. Bijectors provide a rich class of transformed distributions, from classical examples like the log-normal distribution to sophisticated deep learning models such as masked autoregressive flows.
Layer 2: Model Building
- Joint Distributions (e.g.,
tfp.distributions.JointDistributionSequential
): Joint distributions over one or more possibly-interdependent distributions. For an introduction to modeling with TFP'sJointDistribution
s, check out this colab - Probabilistic layers
(
tfp.layers
): Neural network layers with uncertainty over the functions they represent, extending TensorFlow layers.
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
(
tfp.vi
): 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.
Examples
In addition to the Python notebook tutorials listed in the navigation, there are some example scripts available:
- Variational Autoencoders —Representation learning with a latent code and variational inference.
- Vector-Quantized Autoencoder —Discrete representation learning with vector quantization.
- Bayesian Neural Networks —Neural networks with uncertainty over their weights.
- Bayesian Logistic Regression —Bayesian inference for binary classification.
Report issues
Report bugs or feature requests using the TensorFlow Probability issue tracker.