Stay organized with collections
Save and categorize content based on your preferences.
Introduction
TensorFlow Hub hosts models for a variety of tasks. Models
for the same task are encouraged to implement a common API so that model
consumers can easily exchange them without modifying the code that uses them,
even if they come from different publishers.
The goal is to make exchanging different models for the same task as simple as
switching a string-valued hyperparameter. With that, model consumers can easily
find the best one for their problem.
The Reusable SavedModel API defines general
conventions how to load a SavedModel back into a Python program and reuse it as
part of a bigger TensorFlow model.
Basic usage:
obj=hub.load("path/to/model")# That's tf.saved_model.load() after download.outputs=obj(inputs,training=False)# Invokes the tf.function obj.__call__.
For Keras users, the hub.KerasLayer class relies on this API to wrap the
Reusable SavedModel as a Keras Layer (shielding Keras users from its details),
with inputs and outputs according to the task-specific APIs listed below.
Task-specific APIs
These refine the Reusable SavedModel API with
conventions for particular ML tasks and types of data.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-11 UTC."],[],[],null,["# Common SavedModel APIs for TF Hub\n\n\u003cbr /\u003e\n\nIntroduction\n------------\n\n[TensorFlow Hub](https://tfhub.dev) hosts models for a variety of tasks. Models\nfor the same task are encouraged to implement a common API so that model\nconsumers can easily exchange them without modifying the code that uses them,\neven if they come from different publishers.\n\nThe goal is to make exchanging different models for the same task as simple as\nswitching a string-valued hyperparameter. With that, model consumers can easily\nfind the best one for their problem.\n\nThis directory collects specifications of common APIs for models in the\n[TF2 SavedModel format](../tf2_saved_model). (It replaces the\n[Common Signatures](../common_signatures/index) for the now-deprecated\n[TF1 Hub format](../tf1_hub_module).)\n\nReusable SavedModel: the common foundation\n------------------------------------------\n\nThe [Reusable SavedModel API](../reusable_saved_models) defines general\nconventions how to load a SavedModel back into a Python program and reuse it as\npart of a bigger TensorFlow model.\n\nBasic usage: \n\n obj = hub.load(\"path/to/model\") # That's tf.saved_model.load() after download.\n outputs = obj(inputs, training=False) # Invokes the tf.function obj.__call__.\n\n| **Key Point:** This uses the object-based interface to restored SavedModels that was added in TensorFlow 2, not the SavedModel signatures for serving.\n\nFor Keras users, the [`hub.KerasLayer`](https://www.tensorflow.org/hub/api_docs/python/hub/KerasLayer) class relies on this API to wrap the\nReusable SavedModel as a Keras Layer (shielding Keras users from its details),\nwith inputs and outputs according to the task-specific APIs listed below.\n\nTask-specific APIs\n------------------\n\nThese refine the [Reusable SavedModel API](../reusable_saved_models) with\nconventions for particular ML tasks and types of data.\n\n- [Image tasks](/hub/common_saved_model_apis/images)\n- [Text tasks](/hub/common_saved_model_apis/text)"]]