TensorFlow Probability: A Layered Library for Bayesian Models Inside TensorFlow
Probabilistic reasoning and statistical analysis in TensorFlow
At a glance
- What is it?
- TensorFlow Probability ships distributions, bijectors, probabilistic layers, MCMC and variational inference as distinct layers on top of TensorFlow, with a JAX substrate available. The design rewards teams already committed to the TensorFlow runtime and penalises anyone who wants a stable API or a small install.
- Who is it for?
- Adopt TensorFlow Probability if your model already lives in TensorFlow and you need distributions, bijectors or MCMC inside the same graph, or if you can use the JAX substrate via `from tensorflow_probability.substrates import jax as tfp`. Do not adopt it if you need a frozen API, a lightweight dependency tree, or a probabilistic language with a compiler and sampler built in.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 6 days ago.
- What is it written in?
- Mainly Jupyter Notebook, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The gap TensorFlow Probability fills for TensorFlow users
TensorFlow gives you numerical operations and automatic differentiation. It does not give you a probability distribution object with a log probability, a sampler, and broadcasting semantics over sample, batch and event dimensions. TensorFlow Probability supplies that layer. The README describes it as a library for probabilistic reasoning and statistical analysis in TensorFlow, and lists three things it adds to the base runtime: integration of probabilistic methods with deep networks, gradient-based inference through automatic differentiation, and scalability to large datasets and models via hardware acceleration and distributed computation. The intended reader is someone building a model that has to express uncertainty, not someone doing descriptive statistics. Concretely, that means hierarchical models, latent variable models, Bayesian neural network layers, and covariance estimation, all of which appear as notebooks under `tensorflow_probability/examples/`. The project is a Jupyter Notebook repository by primary language, which tells you where the documentation effort goes: the runnable examples are notebooks, and the library itself is Python underneath them.
Four layers, and what sits in each
The README structures the library explicitly. Layer 0 is TensorFlow itself, and the notable artefact is the LinearOperator class, which the README says enables matrix-free implementations that exploit special structure such as diagonal or low-rank matrices. That class was built by the TensorFlow Probability team and now lives in core TensorFlow as `tf.linalg`. Layer 1 holds statistical building blocks: `tfp.distributions` for probability distributions with batch and broadcasting semantics, and `tfp.bijectors` for reversible, composable transformations of random variables. Bijectors are how the library gets from a simple base distribution to something like a log-normal or a masked autoregressive flow. Layer 2 is model building: joint distributions such as `tfp.distributions.JointDistributionSequential`, and `tfp.layers`, which are neural network layers carrying uncertainty over the functions they represent. Layer 3 is inference: `tfp.mcmc` for sampling-based integration with Hamiltonian Monte Carlo and random-walk Metropolis-Hastings plus custom transition kernels, `tfp.vi` for optimisation-based integration, `tfp.optimizer` for stochastic optimisation methods including Stochastic Gradient Langevin Dynamics, and `tfp.monte_carlo` for Monte Carlo expectations. The layering is not decoration. It tells you which import you need for which job, and it means you can use distributions and bijectors without ever touching the inference machinery.
The JAX substrate is a separate code path, not a flag
The README states that TFP also works as Tensor-friendly Probability in pure JAX, with the import `from tensorflow_probability.substrates import jax as tfp`. This is the most consequential detail in the repository for anyone deciding whether to adopt it. The same module names appear under a different substrate, so code written against `tfp.distributions` can, in principle, be pointed at JAX instead of TensorFlow. The README links to a dedicated example notebook for TensorFlow Probability on JAX rather than documenting the differences inline, which means the compatibility surface between the two substrates is something you have to establish from the examples. Treat the substrate choice as an architectural decision made at the start of a project. Switching later means auditing every call site for backend-specific behaviour, and the notebook examples are the only stated reference for how the two compare.
Installing it and pinning the version
The README does not include an install command, so the pip package name and the exact extras are not something this material confirms. What the material does confirm is the release cadence: v0.25.0 in November 2024, v0.24.0 in March 2024, v0.23.0 in November 2023. That is roughly two releases a year, with the 0.x major version signalling that interfaces are not frozen. The README says so directly: TensorFlow Probability is under active development and interfaces may change at any time. The practical consequence is that you pin the version in your dependency file and you test upgrades rather than absorbing them. Because the library is part of the TensorFlow ecosystem and depends on TensorFlow, the version you can use is bounded by the TensorFlow version you already run. Check the release notes for the TFP version you intend to install and confirm the TensorFlow range it targets before you change anything. The Apache-2.0 licence is permissive and permits commercial use, modification and redistribution, but it also means there is no warranty; this is a general statement about the licence text, not legal advice, and your organisation's policy on Apache-2.0 dependencies is the thing that decides whether you can ship it.
Where the library gets in your way
The API stability caveat is the first real limitation, and it is stated by the project rather than inferred. Code written against `tfp.mcmc` or `tfp.bijectors` in one release may need edits in the next. The second limitation is the dependency weight. Using TFP means using TensorFlow, which is a large install and a large runtime, and that cost is paid even if you only want distributions and bijectors. The JAX substrate avoids the TensorFlow runtime but pulls in JAX instead, and the README presents it as an alternative path rather than a way to make TFP small. The third limitation is conceptual rather than technical: the shape semantics. The examples include a notebook titled Understanding TensorFlow Distributions Shapes, described as covering how to distinguish between samples, batches, and events for arbitrarily shaped probabilistic computations. The fact that this needs its own tutorial is the honest signal. Batch and event dimensions interact with broadcasting, and getting them wrong produces silent shape errors or, worse, a model that runs and estimates the wrong thing. If your team has not internalised that distinction, the library will be harder than it looks.
How it differs from Stan and PyMC
The README itself points at the comparison. One of the example notebooks is Hierarchical Linear Models compared among TensorFlow Probability, R, and Stan. Stan and PyMC are probabilistic programming languages: you write a model declaration, and a compiler or an inference engine handles the sampling. TensorFlow Probability is a library of components. You assemble the joint distribution, choose the transition kernel or the variational family, run the optimiser, and manage the tensors yourself. That is more code and more decisions, and it is also why TFP composes with neural network layers in the same graph, which is the case the language-based tools handle less directly. The trade is control against convenience. If your model is a standard hierarchical regression and nothing else, a language with a sampler built in will get you there with less code. If your model is a variational autoencoder with a probabilistic layer in the middle, the library approach is the one that fits, and the examples directory reflects that with scripts such as the vector-quantized autoencoder and the disentangled sequential variational autoencoder.
Maintenance cost and the upgrade decision
The maintenance story follows from the release history and the stated policy. Two releases a year, 0.x versioning, and an explicit warning that interfaces may change mean upgrades are not free. Budget for reading release notes before each version bump and for running your model's test suite against the new release. The notebooks under `tensorflow_probability/examples/` are the closest thing to a compatibility reference, and they are also the thing most likely to break when an interface changes, so treat an update to the examples as a signal about what moved. The Apache-2.0 licence imposes no copyleft obligation on your own code, and it includes a patent grant, which matters for some legal reviews. It also disclaims warranty, so correctness of the inference results is your responsibility. Nothing in the material describes a commercial support offering, so plan on the public issue tracker and the notebook examples as your support surface.
Editorial conclusion
Adopt TensorFlow Probability if your model already lives in TensorFlow and you need distributions, bijectors or MCMC inside the same graph, or if you can use the JAX substrate via `from tensorflow_probability.substrates import jax as tfp`. Do not adopt it if you need a frozen API, a lightweight dependency tree, or a probabilistic language with a compiler and sampler built in. Before committing, verify which release your TensorFlow version supports, confirm whether you need the TensorFlow or JAX substrate, and read the shape semantics notebook so that sample, batch and event dimensions are not a surprise in production code.
Community notes