TensorFlow Hub is a library for reusable machine learning modules.
!pip install "tensorflow_hub>=0.6.0" !pip install "tensorflow>=2.0.0" import tensorflow as tf import tensorflow_hub as hub module_url = "https://tfhub.dev/google/nnlm-en-dim128/2" embed = hub.KerasLayer(module_url) embeddings = embed(["A long sentence.", "single-word", "http://example.com"]) print(embeddings.shape) #(3,128)
TensorFlow Hub is a library for the publication, discovery, and consumption of reusable parts of machine learning models. A module is a self-contained piece of a TensorFlow graph, along with its weights and assets, that can be reused across different tasks in a process known as transfer learning. Transfer learning can:
- Train a model with a smaller dataset,
- Improve generalization, and
- Speed up training.