{"id":13399806,"url":"https://github.com/tensorflow/probability","last_synced_at":"2025-05-12T03:40:54.964Z","repository":{"id":37953039,"uuid":"108053674","full_name":"tensorflow/probability","owner":"tensorflow","description":"Probabilistic reasoning and statistical analysis in TensorFlow","archived":false,"fork":false,"pushed_at":"2025-04-28T23:47:58.000Z","size":160057,"stargazers_count":4331,"open_issues_count":710,"forks_count":1115,"subscribers_count":154,"default_branch":"main","last_synced_at":"2025-05-01T13:51:03.032Z","etag":null,"topics":["bayesian-methods","data-science","deep-learning","machine-learning","neural-networks","probabilistic-programming","statistics","tensorflow"],"latest_commit_sha":null,"homepage":"https://www.tensorflow.org/probability/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-23T23:50:54.000Z","updated_at":"2025-05-01T04:45:56.000Z","dependencies_parsed_at":"2022-08-08T22:30:59.463Z","dependency_job_id":"63f300d9-f5ff-4ce6-b3ec-cee583ce763b","html_url":"https://github.com/tensorflow/probability","commit_stats":{"total_commits":10528,"total_committers":535,"mean_commits":"19.678504672897198","dds":0.8763297872340425,"last_synced_commit":"ca4aa61dff309428ee3e99692dbe5cb7c55a3baa"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fprobability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fprobability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fprobability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Fprobability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorflow","download_url":"https://codeload.github.com/tensorflow/probability/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253670001,"owners_count":21945198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-methods","data-science","deep-learning","machine-learning","neural-networks","probabilistic-programming","statistics","tensorflow"],"created_at":"2024-07-30T19:00:43.257Z","updated_at":"2025-05-12T03:40:54.938Z","avatar_url":"https://github.com/tensorflow.png","language":"Jupyter Notebook","readme":"# TensorFlow Probability\n\nTensorFlow Probability is a library for probabilistic reasoning and statistical\nanalysis in TensorFlow. As part of the TensorFlow ecosystem, TensorFlow\nProbability provides integration of probabilistic methods with deep networks,\ngradient-based inference via automatic differentiation, and scalability to\nlarge datasets and models via hardware acceleration (e.g., GPUs) and distributed\ncomputation.\n\n__TFP also works as \"Tensor-friendly Probability\" in pure JAX!__:\n`from tensorflow_probability.substrates import jax as tfp` --\nLearn more [here](https://www.tensorflow.org/probability/examples/TensorFlow_Probability_on_JAX).\n\nOur probabilistic machine learning tools are structured as follows.\n\n__Layer 0: TensorFlow.__ Numerical operations. In particular, the LinearOperator\nclass enables matrix-free implementations that can exploit special structure\n(diagonal, low-rank, etc.) for efficient computation. It is built and maintained\nby the TensorFlow Probability team and is now part of\n[`tf.linalg`](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/ops/linalg)\nin core TF.\n\n__Layer 1: Statistical Building Blocks__\n\n* Distributions ([`tfp.distributions`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/distributions)):\n  A large collection of probability\n  distributions and related statistics with batch and\n  [broadcasting](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)\n  semantics. See the\n  [Distributions Tutorial](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/TensorFlow_Distributions_Tutorial.ipynb).\n* Bijectors ([`tfp.bijectors`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/bijectors)):\n  Reversible and composable transformations of random variables. Bijectors\n  provide a rich class of transformed distributions, from classical examples\n  like the\n  [log-normal distribution](https://en.wikipedia.org/wiki/Log-normal_distribution)\n  to sophisticated deep learning models such as\n  [masked autoregressive flows](https://arxiv.org/abs/1705.07057).\n\n__Layer 2: Model Building__\n\n* Joint Distributions (e.g., [`tfp.distributions.JointDistributionSequential`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/distributions/joint_distribution_sequential.py)):\n    Joint distributions over one or more possibly-interdependent distributions.\n    For an introduction to modeling with TFP's `JointDistribution`s, check out\n    [this colab](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Modeling_with_JointDistribution.ipynb)\n* Probabilistic Layers ([`tfp.layers`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/layers)):\n  Neural network layers with uncertainty over the functions they represent,\n  extending TensorFlow Layers.\n\n__Layer 3: Probabilistic Inference__\n\n* Markov chain Monte Carlo ([`tfp.mcmc`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/mcmc)):\n  Algorithms for approximating integrals via sampling. Includes\n  [Hamiltonian Monte Carlo](https://en.wikipedia.org/wiki/Hamiltonian_Monte_Carlo),\n  random-walk Metropolis-Hastings, and the ability to build custom transition\n  kernels.\n* Variational Inference ([`tfp.vi`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/vi)):\n  Algorithms for approximating integrals via optimization.\n* Optimizers ([`tfp.optimizer`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/python/optimizer)):\n  Stochastic optimization methods, extending TensorFlow Optimizers. Includes\n  [Stochastic Gradient Langevin Dynamics](http://www.icml-2011.org/papers/398_icmlpaper.pdf).\n* Monte Carlo ([`tfp.monte_carlo`](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/python/monte_carlo)):\n  Tools for computing Monte Carlo expectations.\n\nTensorFlow Probability is under active development. Interfaces may change at any\ntime.\n\n## Examples\n\nSee [`tensorflow_probability/examples/`](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/examples/)\nfor end-to-end examples. It includes tutorial notebooks such as:\n\n* [Linear Mixed Effects Models](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Linear_Mixed_Effects_Models.ipynb).\n  A hierarchical linear model for sharing statistical strength across examples.\n* [Eight Schools](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Eight_Schools.ipynb).\n  A hierarchical normal model for exchangeable treatment effects.\n* [Hierarchical Linear Models](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/HLM_TFP_R_Stan.ipynb).\n  Hierarchical linear models compared among TensorFlow Probability, R, and Stan.\n* [Bayesian Gaussian Mixture Models](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Bayesian_Gaussian_Mixture_Model.ipynb).\n  Clustering with a probabilistic generative model.\n* [Probabilistic Principal Components Analysis](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Probabilistic_PCA.ipynb).\n  Dimensionality reduction with latent variables.\n* [Gaussian Copulas](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Gaussian_Copula.ipynb).\n  Probability distributions for capturing dependence across random variables.\n* [TensorFlow Distributions: A Gentle Introduction](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/TensorFlow_Distributions_Tutorial.ipynb).\n  Introduction to TensorFlow Distributions.\n* [Understanding TensorFlow Distributions Shapes](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/Understanding_TensorFlow_Distributions_Shapes.ipynb).\n  How to distinguish between samples, batches, and events for arbitrarily shaped\n  probabilistic computations.\n* [TensorFlow Probability Case Study: Covariance Estimation](https://github.com/tensorflow/probability/blob/main/tensorflow_probability/examples/jupyter_notebooks/TensorFlow_Probability_Case_Study_Covariance_Estimation.ipynb).\n  A user's case study in applying TensorFlow Probability to estimate covariances.\n\nIt also includes example scripts such as:\n\n  Representation learning with a latent code and variational inference.\n* [Vector-Quantized Autoencoder](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/examples/vq_vae.py).\n  Discrete representation learning with vector quantization.\n* [Disentangled Sequential Variational Autoencoder](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/examples/disentangled_vae.py)\n  Disentangled representation learning over sequences with variational inference.\n* [Bayesian Neural Networks](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/examples/bayesian_neural_network.py).\n  Neural networks with uncertainty over their weights.\n* [Bayesian Logistic Regression](https://github.com/tensorflow/probability/tree/main/tensorflow_probability/examples/logistic_regression.py).\n  Bayesian inference for binary classification.\n\n## Installation\n\nFor additional details on installing TensorFlow, guidance installing\nprerequisites, and (optionally) setting up virtual environments, see the\n[TensorFlow installation guide](https://www.tensorflow.org/install).\n\n### Stable Builds\n\nTo install the latest stable version, run the following:\n\n```shell\n# Notes:\n\n# - The `--upgrade` flag ensures you'll get the latest version.\n# - The `--user` flag ensures the packages are installed to your user directory\n#   rather than the system directory.\n# - TensorFlow 2 packages require a pip \u003e= 19.0\npython -m pip install --upgrade --user pip\npython -m pip install --upgrade --user tensorflow tensorflow_probability\n```\n\nFor CPU-only usage (and a smaller install), install with `tensorflow-cpu`.\n\nTo use a pre-2.0 version of TensorFlow, run:\n\n```shell\npython -m pip install --upgrade --user \"tensorflow\u003c2\" \"tensorflow_probability\u003c0.9\"\n```\n\nNote: Since [TensorFlow](https://www.tensorflow.org/install) is *not* included\nas a dependency of the TensorFlow Probability package (in `setup.py`), you must\nexplicitly install the TensorFlow package (`tensorflow` or `tensorflow-cpu`).\nThis allows us to maintain one package instead of separate packages for CPU and\nGPU-enabled TensorFlow. See the\n[TFP release notes](https://github.com/tensorflow/probability/releases) for more\ndetails about dependencies between TensorFlow and TensorFlow Probability.\n\n\n### Nightly Builds\n\nThere are also nightly builds of TensorFlow Probability under the pip package\n`tfp-nightly`, which depends on one of `tf-nightly` or `tf-nightly-cpu`.\nNightly builds include newer features, but may be less stable than the\nversioned releases. Both stable and nightly docs are available\n[here](https://www.tensorflow.org/probability/api_docs/python/tfp?version=nightly).\n\n```shell\npython -m pip install --upgrade --user tf-nightly tfp-nightly\n```\n\n### Installing from Source\n\nYou can also install from source. This requires the [Bazel](\nhttps://bazel.build/) build system. It is highly recommended that you install\nthe nightly build of TensorFlow (`tf-nightly`) before trying to build\nTensorFlow Probability from source. The most recent version of Bazel that TFP\ncurrently supports is 6.4.0; support for 7.0.0+ is WIP.\n\n```shell\n# sudo apt-get install bazel git python-pip  # Ubuntu; others, see above links.\npython -m pip install --upgrade --user tf-nightly\ngit clone https://github.com/tensorflow/probability.git\ncd probability\nbazel build --copt=-O3 --copt=-march=native :pip_pkg\nPKGDIR=$(mktemp -d)\n./bazel-bin/pip_pkg $PKGDIR\npython -m pip install --upgrade --user $PKGDIR/*.whl\n```\n\n## Community\n\nAs part of TensorFlow, we're committed to fostering an open and welcoming\nenvironment.\n\n* [Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow): Ask\n  or answer technical questions.\n* [GitHub](https://github.com/tensorflow/probability/issues): Report bugs or\n  make feature requests.\n* [TensorFlow Blog](https://blog.tensorflow.org/): Stay up to date on content\n  from the TensorFlow team and best articles from the community.\n* [Youtube Channel](http://youtube.com/tensorflow/): Follow TensorFlow shows.\n* [tfprobability@tensorflow.org](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfprobability):\n  Open mailing list for discussion and questions.\n\nSee the [TensorFlow Community](https://www.tensorflow.org/community/) page for\nmore details. Check out our latest publicity here:\n\n+ [Coffee with a Googler: Probabilistic Machine Learning in TensorFlow](\n  https://www.youtube.com/watch?v=BjUkL8DFH5Q)\n+ [Introducing TensorFlow Probability](\n  https://medium.com/tensorflow/introducing-tensorflow-probability-dca4c304e245)\n\n## Contributing\n\nWe're eager to collaborate with you! See [`CONTRIBUTING.md`](CONTRIBUTING.md)\nfor a guide on how to contribute. This project adheres to TensorFlow's\n[code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to\nuphold this code.\n\n## References\n\nIf you use TensorFlow Probability in a paper, please cite:\n\n+ _TensorFlow Distributions._ Joshua V. Dillon, Ian Langmore, Dustin Tran,\nEugene Brevdo, Srinivas Vasudevan, Dave Moore, Brian Patton, Alex Alemi, Matt\nHoffman, Rif A. Saurous.\n[arXiv preprint arXiv:1711.10604, 2017](https://arxiv.org/abs/1711.10604).\n\n(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.)\n","funding_links":[],"categories":["Jupyter Notebook","其他_机器学习与深度学习","Probabilistic Programming Languages (PPL) (a.k.a. Build your own Topic Model)","\u003cspan id=\"head30\"\u003e3.4. Bayesian Inference\u003c/span\u003e","Deep Learning Framework","📦 Packages \u003csmall\u003e(15)\u003c/small\u003e","Software","概率统计","Statistics ##","Uncategorized"],"sub_categories":["Embedding based Topic Models","3.2.5. First Order Methods","High-Level DL APIs","\u003cimg src=\"assets/tensorflow.svg\" alt=\"TensorFlow\" height=\"20px\"\u003e \u0026nbsp;TensorFlow Packages","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fprobability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorflow%2Fprobability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Fprobability/lists"}