TensorFlow Hub 是用于存储可重用机器学习资产的开放仓库和库。tfhub.dev 仓库中提供了许多预训练模型:文本嵌入向量、图像分类模型、TF.js/TFLite 模型等。该仓库向社区贡献者开放。
借助 tensorflow_hub 库,您可以下载并以最少的代码量在 TensorFlow 程序中重用这些模型。
tensorflow_hub
import tensorflow_hub as hub model = hub.KerasLayer("https://tfhub.dev/google/nnlm-en-dim128/2") embeddings = model(["The rain in Spain.", "falls", "mainly", "In the plain!"]) print(embeddings.shape) #(4,128)
在 tfhub.dev 上查找模型
在 tfhub.dev 上发布模型
TensorFlow Hub 库
安装 TensorFlow Hub
库概览
关注教程