TensorFlow Hub
Stay organized with collections
Save and categorize content based on your preferences.
TensorFlow Hub is an open repository and library for reusable machine learning.
The tfhub.dev repository provides many pre-trained models:
text embeddings, image classification models, TF.js/TFLite models and much more.
The repository is open to
community contributors.
The tensorflow_hub
library lets you
download and reuse them in your TensorFlow program with a minimum amount of
code.
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)
Next Steps
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-07 UTC.
[null,null,["Last updated 2023-10-07 UTC."],[],[],null,["# TensorFlow Hub\n\n\u003cbr /\u003e\n\nTensorFlow Hub is an open repository and library for reusable machine learning.\nThe [tfhub.dev](https://tfhub.dev) repository provides many pre-trained models:\ntext embeddings, image classification models, TF.js/TFLite models and much more.\nThe repository is open to\n[community contributors](https://tfhub.dev/s?subtype=publisher).\n\nThe [`tensorflow_hub`](https://github.com/tensorflow/hub) library lets you\ndownload and reuse them in your TensorFlow program with a minimum amount of\ncode. \n\n import tensorflow_hub as hub\n\n model = hub.KerasLayer(\"https://tfhub.dev/google/nnlm-en-dim128/2\")\n embeddings = model([\"The rain in Spain.\", \"falls\",\n \"mainly\", \"In the plain!\"])\n\n print(embeddings.shape) #(4,128)\n\nNext Steps\n----------\n\n- [Find models on tfhub.dev](https://tfhub.dev)\n- [Publish models on tfhub.dev](/hub/publish)\n- TensorFlow Hub library\n - [Install TensorFlow Hub](/hub/installation)\n - [Library overview](/hub/lib_overview)\n- [Follow tutorials](/hub/tutorials)"]]