TensorFlow Probability Nightly

0.26.0.dev20260415 · active · verified Thu Apr 16

TensorFlow Probability (TFP) is a library for probabilistic modeling and statistical inference built on TensorFlow. This `tfp-nightly` package provides the latest pre-release versions of TFP, offering cutting-edge features and bug fixes. It is typically updated daily and is rigorously tested against nightly builds of TensorFlow and JAX. The current version is 0.26.0.dev20260415.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic Normal distribution, sample from it, calculate log probabilities, and apply a bijector to transform it into a LogNormal distribution. It showcases the core `distributions` and `bijectors` modules of TensorFlow Probability.

import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
tfb = tfp.bijectors

# Create a Normal distribution
mean = tf.constant(0.0, dtype=tf.float32)
stddev = tf.constant(1.0, dtype=tf.float32)
normal_dist = tfd.Normal(loc=mean, scale=stddev)

# Sample from the distribution
samples = normal_dist.sample(10)
print("Samples from Normal distribution:", samples)

# Calculate log probability
log_prob = normal_dist.log_prob(0.5)
print("Log probability of 0.5:", log_prob)

# Demonstrate a bijector (e.g., Exp) to create a LogNormal distribution
exp_bijector = tfb.Exp()
log_normal_dist = exp_bijector(normal_dist)

# Sample from the transformed distribution
log_normal_samples = log_normal_dist.sample(5)
print("Samples from LogNormal distribution (via Exp bijector):", log_normal_samples)

view raw JSON →