安装
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
稳定版本
安装最新版本的 TensorFlow Probability:
pip install --upgrade tensorflow-probability
TensorFlow Probability 依赖于最新稳定版本的 TensorFlow(pip 软件包 tensorflow
)。有关 TensorFlow 和 TensorFlow Probability 之间依赖关系的详细信息,请参阅 TFP 版本说明。
注:由于 TensorFlow 不作为 TensorFlow Probability 软件包(在 setup.py
中)的依赖项包含在内,因此您必须显式安装 TensorFlow 软件包(tensorflow
或 tensorflow-gpu
)。这样,我们便可为支持 CPU 和 GPU 的 TensorFlow 维护一个软件包,而不用维护单独的软件包。
要强制执行特定于 Python 3 的安装,请将上述命令中的 pip
替换为 pip3
。有关其他安装帮助、安装前提条件指导以及(可选)设置虚拟环境的信息,请参阅 TensorFlow 安装指南。
Nightly 版本
此外,pip 软件包 tfp-nightly
下还有 Nightly 版本的 TensorFlow Probability,此版本依赖于 tf-nightly
和 tf-nightly-gpu
之一。Nightly 版本包含较新的功能,但可能不如带版本号的版本稳定。
从源代码安装
您也可以从源代码安装。这需要 Bazel 构建系统。强烈建议您在尝试从源代码构建 TensorFlow Probability 之前安装 Nightly 版本的 TensorFlow (tf-nightly
)。
sudo apt-get install bazel git python-pip
python -m pip install --upgrade --user tf-nightly
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
python -m pip install --upgrade --user $PKGDIR/*.whl
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2022-06-07。
[null,null,["最后更新时间 (UTC):2022-06-07。"],[],[],null,["# Install\n\nStable builds\n-------------\n\nInstall the latest version of TensorFlow Probability: \n\n```bash\npip install --upgrade tensorflow-probability\n```\n\nTensorFlow Probability depends on a recent stable release of\n[TensorFlow](https://www.tensorflow.org/install) (pip package `tensorflow`). See\nthe [TFP release notes](https://github.com/tensorflow/probability/releases) for\ndetails about dependencies between TensorFlow and TensorFlow Probability.\n| **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.\n\nTo force a Python 3-specific install, replace `pip` with `pip3` in the above\ncommands. For additional installation help, guidance installing prerequisites,\nand (optionally) setting up virtual environments, see the [TensorFlow\ninstallation guide](https://www.tensorflow.org/install).\n\nNightly builds\n--------------\n\nThere are also nightly builds of TensorFlow Probability under the pip package\n`tfp-nightly`, which depend on one of `tf-nightly` and `tf-nightly-gpu`. Nightly\nbuilds include newer features, but may be less stable than the versioned\nreleases.\n\nInstall from source\n-------------------\n\nYou can also install from source. This requires the\n[Bazel](https://bazel.build/) build system. It is highly recommended\nthat you install the nightly build of TensorFlow (`tf-nightly`) before trying to\nbuild TensorFlow Probability from source. \n\n sudo apt-get install bazel git python-pip\n python -m pip install --upgrade --user tf-nightly\n git clone https://github.com/tensorflow/probability.git\n cd probability\n bazel build --copt=-O3 --copt=-march=native :pip_pkg\n PKGDIR=$(mktemp -d)\n ./bazel-bin/pip_pkg $PKGDIR\n python -m pip install --upgrade --user $PKGDIR/*.whl"]]