Watch talks from the 2019 TensorFlow Dev Summit Watch now

TensorFlow Hub is a library for reusable machine learning modules.

import tensorflow as tf
import tensorflow_hub as hub

with tf.Graph().as_default():
  module_url = ""
  embed = hub.Module(module_url)
  embeddings = embed(["A long sentence.", "single-word",

  with tf.Session() as sess:

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.