TensorFlow Hub

TensorFlow Hub 是開放原始碼的存放區和程式庫,可用於重複使用的機器學習。tfhub.dev 存放區提供許多預先訓練的模型:文字嵌入、圖片分類模型、TF.js/TFLite 模型等等。這個存放區開放給社群貢獻者

您可以使用 tensorflow_hub 程式庫,以最少的程式碼在您的 TensorFlow 程式中下載並重複使用這些模型。

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)

後續步驟