This is the preferred API to load a Hub module in low-level TensorFlow 2.
Users of higher-level frameworks like Keras should use the framework's
corresponding wrapper, like hub.KerasLayer.
This function is roughly equivalent to the TF2 function
tf.saved_model.load() on the result of hub.resolve(handle). Calling this
function requires TF 1.14 or newer. It can be called both in eager and graph
mode.
This function can handle the deprecated TF1 Hub format to the extent
that tf.saved_model.load() in TF2 does. In particular, the returned object
has attributes
.variables: a list of variables from the loaded object;
.signatures: a dict of TF2 ConcreteFunctions, keyed by signature names,
that take tensor kwargs and return a tensor dict.
However, the information imported by hub.Module into the collections of a
tf.Graph is lost (e.g., regularization losses and update ops).
Args
handle
(string) the Module handle to resolve; see hub.resolve().
tags
A set of strings specifying the graph variant to use, if loading from
a v1 module.
options
Optional, tf.saved_model.LoadOptions object that specifies
options for loading. This argument can only be used from TensorFlow 2.3
onwards.
Returns
A trackable object (see tf.saved_model.load() documentation for details).
Raises
NotImplementedError
If the code is running against incompatible (1.x)
version of TF.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# hub.load\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/hub/blob/v0.16.1/tensorflow_hub/module_v2.py#L58-L128) |\n\nResolves a handle and loads the resulting module. \n\n hub.load(\n handle, tags=None, options=None\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [BERT Experts from TF-Hub](https://www.tensorflow.org/hub/tutorials/bert_experts) - [Image Super Resolution using ESRGAN](https://www.tensorflow.org/hub/tutorials/image_enhancing) - [MoveNet: Ultra fast and accurate pose detection model.](https://www.tensorflow.org/hub/tutorials/movenet) - [MoViNet for streaming action recognition](https://www.tensorflow.org/hub/tutorials/movinet) - [Frame interpolation using the FILM model](https://www.tensorflow.org/hub/tutorials/tf_hub_film_example) |\n\nThis is the preferred API to load a Hub module in low-level TensorFlow 2.\nUsers of higher-level frameworks like Keras should use the framework's\ncorresponding wrapper, like hub.KerasLayer.\n\nThis function is roughly equivalent to the TF2 function\n[`tf.saved_model.load()`](https://www.tensorflow.org/api_docs/python/tf/saved_model/load) on the result of [`hub.resolve(handle)`](../hub/resolve). Calling this\nfunction requires TF 1.14 or newer. It can be called both in eager and graph\nmode.\n| **Note:** Using in a tf.compat.v1.Session with variables placed on parameter servers requires setting `experimental.share_cluster_devices_in_session` within the [`tf.compat.v1.ConfigProto`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/ConfigProto). (It becomes non-experimental in TF2.2.)\n\nThis function can handle the deprecated TF1 Hub format to the extent\nthat [`tf.saved_model.load()`](https://www.tensorflow.org/api_docs/python/tf/saved_model/load) in TF2 does. In particular, the returned object\nhas attributes\n\n- `.variables`: a list of variables from the loaded object;\n- `.signatures`: a dict of TF2 ConcreteFunctions, keyed by signature names, that take tensor kwargs and return a tensor dict. However, the information imported by hub.Module into the collections of a tf.Graph is lost (e.g., regularization losses and update ops).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `handle` | (string) the Module handle to resolve; see hub.resolve(). |\n| `tags` | A set of strings specifying the graph variant to use, if loading from a v1 module. |\n| `options` | Optional, [`tf.saved_model.LoadOptions`](https://www.tensorflow.org/api_docs/python/tf/saved_model/LoadOptions) object that specifies options for loading. This argument can only be used from TensorFlow 2.3 onwards. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A trackable object (see tf.saved_model.load() documentation for details). ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-----------------------|------------------------------------------------------------------|\n| `NotImplementedError` | If the code is running against incompatible (1.x) version of TF. |\n\n\u003cbr /\u003e"]]