import tensorflow as tf 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.to_float(labels), model=model) # ==> coeffs is approximately [1.618] (We're golden!)
TensorFlow Probability (TFP) is a Python library built on TensorFlow that makes it easy to combine probabilistic models and deep learning on modern hardware (TPU, GPU). It's for data scientists, statisticians, ML researchers, and practitioners who want to encode 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 the Edward2 language.
- Variational inference and Markov chain Monte Carlo.
- Optimizers such as Nelder-Mead, BFGS, and SGLD.
An introduction to probabilistic programming
Bayesian Methods for Hackers, an introductory, hands-on tutorial, is now available with examples in TensorFlow Probability.