安装 TensorFlow 模型优化
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
建议在安装之前创建一个 Python 虚拟环境。请参阅 TensorFlow 安装指南获取更多信息 。
稳定版本
要安装最新版本,请运行以下代码:
# Installing with the `--upgrade` flag ensures you'll get the latest version. pip install --user --upgrade tensorflow-model-optimization
有关版本的详细信息,请参阅版本说明。
有关所需的 TensorFlow 版本和其他兼容性信息,请根据您打算使用的技术,参阅其“概述”页面的“API 兼容性矩阵”部分。例如,对于剪枝,“概述”页面位于此处。
由于TensorFlow 未包含在 TensorFlow 模型优化软件包(位于 setup.py
中)的依赖项中,您必须显式安装 TensorFlow 软件包(tf-nightly
或 tf-nightly-gpu
)。如此一来,我们只需维护一个软件包,而无需分别维护支持 CPU 和 GPU 的 TensorFlow 软件包。
从源代码安装
您也可以从源代码安装。这需要 Bazel 构建系统。
# To install dependencies on Ubuntu: # sudo apt-get install bazel git python-pip # For other platforms, see Bazel docs above. git clone https://github.com/tensorflow/model-optimization.git cd model_optimization bazel build --copt=-O3 --copt=-march=native :pip_pkg PKGDIR=$(mktemp -d) ./bazel-bin/pip_pkg $PKGDIR pip install --user --upgrade $PKGDIR/*.whl
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2021-08-16。
[null,null,["最后更新时间 (UTC):2021-08-16。"],[],[],null,["# Install TensorFlow Model Optimization\n\nIt is recommended to create a Python virtual environment before proceeding to\nthe installation. Please see the TensorFlow installation\n[guide](https://www.tensorflow.org/install/pip#2.-create-a-virtual-environment-recommended)\nfor more information.\n\n### Stable Builds\n\nTo install the latest version, run the following: \n\n # Installing with the `--upgrade` flag ensures you'll get the latest version.\n pip install --user --upgrade tensorflow-model-optimization\n\nFor release details, see our\n[release notes](https://github.com/tensorflow/model-optimization/releases).\n\nFor the required version of TensorFlow and other compatibility information, see\nthe API Compatibility Matrix section of the Overview page for the technique you\nintend to use. For instance, for pruning, the Overview page is\n[here](https://www.tensorflow.org/model_optimization/guide/pruning).\n\nSince TensorFlow is *not* included as a dependency of the TensorFlow Model\nOptimization package (in `setup.py`), you must explicitly install the TensorFlow\npackage (`tf-nightly` or `tf-nightly-gpu`). This allows us to maintain one\npackage instead of separate packages for CPU and GPU-enabled TensorFlow.\n\n### Installing from Source\n\nYou can also install from source. This requires the\n[Bazel](https://bazel.build/) build system. \n\n # To install dependencies on Ubuntu:\n # sudo apt-get install bazel git python-pip\n # For other platforms, see Bazel docs above.\n git clone https://github.com/tensorflow/model-optimization.git\n cd model-optimization\n bazel build --copt=-O3 --copt=-march=native :pip_pkg\n PKGDIR=$(mktemp -d)\n ./bazel-bin/pip_pkg $PKGDIR\n pip install --user --upgrade $PKGDIR/*.whl"]]