TensorFlow Probability
- TensorFlow Probability Library
TensorFlow Probability (TFP) is a Python library for statistical analysis and probabilistic reasoning in TensorFlow. It's intended for data scientists, statisticians, ML researchers, and practitioners who want to use domain knowledge to understand data and make predictions.
TFP includes:
- A wide selection of probability distributions and bijectors.
- Tools to build deep probabilistic models, including probabilistic layers and a `JointDistribution` abstraction.
- Variational inference and Markov chain Monte Carlo.
- Optimizers such as Nelder-Mead, BFGS, and SGLD.
Since TFP inherits the benefits of TensorFlow, you can build, fit, and deploy a model using a single language throughout the lifecycle of model exploration and production. TFP is open source and available on GitHub. To get started, see the TensorFlow Probability Guide.
- Reasons To Use TensorFlow
TensorFlow Probability is a library for probabilistic reasoning and statistical analysis.
Here are some reasons to use TensorFlow Probability:
- You want to build a generative model of data, reasoning about its hidden processes
- You need to quantify the uncertainty in your predictions, as opposed to predicting a single value
- Your training set has a large number of features relative to the number of data points
Here are some GitHub resources for TensorFlow Probability:
- A Tour of TensorFlow Probability: A GitHub page that supports modeling, inference, and criticism through composition of low-level modular components
- rstudio/tfprobability: An R interface to TensorFlow Probability
- Statistical Rethinking (2nd Edition) with Tensorflow Probability: A repository that provides Jupyter notebooks that port various R code fragments found in the chapters of Statistical Rethinking 2nd Edition
- Sample Code
import tensorflow_probability as tfp
# Pretend to load synthetic data set.
features = tfp.distributions.Normal(loc=0., scale=1.).sample(int(100e3))
labels = tfp.distributions.Bernoulli(logits=1.618 * features).sample()
# Specify model.
model = tfp.glm.Bernoulli()
# Fit model given data.
coeffs, linear_response, is_converged, num_iter = tfp.glm.fit(
model_matrix=features[:, tf.newaxis],
response=tf.cast(labels, dtype=tf.float32),
model=model)
# ==> coeffs is approximately [1.618] (We're golden!)