TensorFlow Probability

TensorFlow中的概率推理和统计分析。「Probabilistic reasoning and statistical analysis in TensorFlow」

Github星跟蹤圖

TensorFlow Probability

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 via automatic differentiation, and scalability to
large datasets and models via hardware acceleration (e.g., GPUs) and distributed
computation.

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 special structure
(diagonal, low-rank, etc.) for efficient computation. It is built and maintained
by the TensorFlow Probability team and is now part of
tf.linalg
in core TF.

Layer 1: Statistical Building Blocks

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's JointDistributions, 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 via 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. Interfaces may change at any
time.

Examples

See tensorflow_probability/examples/
for end-to-end examples. It includes tutorial notebooks such as:

It also includes example scripts such as:

Installation

For additional details on installing TensorFlow, guidance installing
prerequisites, and (optionally) setting up virtual environments, see the
TensorFlow installation guide.

Stable Builds

To install the latest stable version, run the following:

# Notes:

# - The `--upgrade` flag ensures you'll get the latest version.
# - The `--user` flag ensures the packages are installed to your user directory
#   rather than the system directory.
# - TensorFlow 2 packages require a pip >= 19.0
python -m pip install --upgrade --user pip
python -m pip install --upgrade --user tensorflow tensorflow_probability

For CPU-only usage (and a smaller install), install with tensorflow-cpu.

To use a pre-2.0 version of TensorFlow, run:

python -m pip install --upgrade --user "tensorflow<2" "tensorflow_probability<0.9"

Note: Since TensorFlow is not included
as a dependency of the TensorFlow Probability package (in setup.py), you must
explicitly install the TensorFlow package (tensorflow or tensorflow-gpu).
This allows us to maintain one package instead of separate packages for CPU and
GPU-enabled TensorFlow. See the
TFP release notes for more
details about dependencies between TensorFlow and TensorFlow Probability.

Nightly Builds

There are also nightly builds of TensorFlow Probability under the pip package
tfp-nightly, which depends on one of tf-nightly or tf-nightly-cpu.
Nightly builds include newer features, but may be less stable than the
versioned releases. Both stable and nightly docs are available
here.

python -m pip install --upgrade --user tf-nightly tfp-nightly

Installing from Source

You can also install from source. This requires the Bazel build system.

# sudo apt-get install bazel git python-pip  # Ubuntu; others, see above links.
git clone https://github.com/tensorflow/probability.git
cd probability
bazel build --copt=-O3 --copt=-march=native :pip_pkg
PKGDIR=$(mktemp -d)
./bazel-bin/pip_pkg $PKGDIR
pip install --user --upgrade $PKGDIR/*.whl

Community

As part of TensorFlow, we're committed to fostering an open and welcoming
environment.

See the TensorFlow Community page for
more details. Check out our latest publicity here:

Contributing

We're eager to collaborate with you! See CONTRIBUTING.md
for a guide on how to contribute. This project adheres to TensorFlow's
code of conduct. By participating, you are expected to
uphold this code.

References

If you use TensorFlow Probability in a paper, please cite:

  • TensorFlow Distributions. Joshua V. Dillon, Ian Langmore, Dustin Tran,
    Eugene Brevdo, Srinivas Vasudevan, Dave Moore, Brian Patton, Alex Alemi, Matt
    Hoffman, Rif A. Saurous.
    arXiv preprint arXiv:1711.10604, 2017.

(We're aware there's a lot more to TensorFlow Probability than Distributions, but the Distributions paper lays out our vision and is a fine thing to cite for now.)

主要指標

概覽
名稱與所有者tensorflow/probability
主編程語言Jupyter Notebook
編程語言Python (語言數: 4)
平台
許可證Apache License 2.0
所有者活动
創建於2017-10-23 23:50:54
推送於2025-05-23 00:35:33
最后一次提交
發布數53
最新版本名稱v0.25.0 (發布於 )
第一版名稱v0.1.0-rc0 (發布於 )
用户参与
星數4.3k
關注者數154
派生數1.1k
提交數12.2k
已啟用問題?
問題數1404
打開的問題數640
拉請求數276
打開的拉請求數72
關閉的拉請求數124
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?