安装
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
安装 tensorflow_hub
tensorflow_hub
库可与 TensorFlow 1 和 TensorFlow 2 一起安装。我们建议新用户立即从 TensorFlow 2 开始,并且当前用户应升级到此版本。
与 TensorFlow 2 一起使用
像往常一样使用 pip 来安装 TensorFlow 2。(有关 GPU 支持的更多说明,请参阅相关文档。)随后安装当前版本的 tensorflow-hub
(必须为 0.5.0 或更高版本)。
$ pip install "tensorflow>=2.0.0"
$ pip install --upgrade tensorflow-hub
TensorFlow Hub 的 TF1 样式 API 适用于 TensorFlow 2 的 v1 兼容模式。
与旧版 TensorFlow 1 一起使用
TensorFlow 1.15 是 TensorFlow 1.x 仍受 tensorflow_hub
库(自版本 0.11.0 起)支持的唯一版本。TensorFlow 1.15 默认采用与 TF1 兼容的行为,但其底层包含了许多 TF2 功能,允许使用 TensorFlow Hub 的 TF2 样式 API。
$ pip install "tensorflow>=1.15,<2.0"
$ pip install --upgrade tensorflow-hub
使用预发布版本
pip 软件包 tf-nightly
和 tf-hub-nightly
是从 GitHub 上的源代码自动构建的,没有版本测试。这样,开发者无需从源代码构建便可试用最新代码。
$ pip install tf-nightly
$ pip install --upgrade tf-hub-nightly
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-01-11。
[null,null,["最后更新时间 (UTC):2024-01-11。"],[],[],null,["# Installation\n\nInstalling tensorflow_hub\n-------------------------\n\nThe `tensorflow_hub` library can be installed alongside TensorFlow 1 and\nTensorFlow 2. We recommend that new users start with TensorFlow 2 right away,\nand current users upgrade to it.\n\n### Use with TensorFlow 2\n\nUse [pip](https://pip.pypa.io/) to\n[install TensorFlow 2](https://www.tensorflow.org/install) as usual. (See there\nfor extra instructions about GPU support.) Then install a current version of\n[`tensorflow-hub`](https://pypi.org/project/tensorflow-hub/) next to it (must be\n0.5.0 or newer). \n\n $ pip install \"tensorflow\u003e=2.0.0\"\n $ pip install --upgrade tensorflow-hub\n\nThe TF1-style API of TensorFlow Hub works with the v1 compatibility mode of\nTensorFlow 2.\n\n### Legacy use with TensorFlow 1\n\nTensorFlow 1.15 is the only version of TensorFlow 1.x still supported by the\n`tensorflow_hub` library (as of release 0.11.0). TensorFlow 1.15 defaults to\nTF1-compatible behavior but contains many TF2 features under the hood to allow\nsome use of TensorFlow Hub's TF2-style APIs. \n\n $ pip install \"tensorflow\u003e=1.15,\u003c2.0\"\n $ pip install --upgrade tensorflow-hub\n\n### Use of pre-release versions\n\nThe pip packages `tf-nightly` and `tf-hub-nightly` are built automatically from\nthe source code on github, with no release testing. This lets developers try out\nthe latest code without [building from source](/hub/build_from_source). \n\n $ pip install tf-nightly\n $ pip install --upgrade tf-hub-nightly\n\nNext Steps\n----------\n\n- [Library overview](/hub/lib_overview)\n- Tutorials:\n - [Text classification](https://github.com/tensorflow/docs/blob/master/site/en/hub/tutorials/tf2_text_classification.ipynb)\n - [Image classification](https://github.com/tensorflow/docs/blob/master/site/en/hub/tutorials/tf2_image_retraining.ipynb)\n - Additional examples [on GitHub](https://github.com/tensorflow/hub/blob/master/examples/README.md)\n- Find models on [tfhub.dev](https://tfhub.dev)."]]