Module: tf.compat.v1.saved_model.loader
Stay organized with collections
Save and categorize content based on your preferences.
Loader functionality for SavedModel with hermetic, language-neutral exports.
Load and restore capability for a SavedModel, which may include multiple meta
graph defs. Each SavedModel is associated with a single checkpoint. Each meta
graph def is saved with one or more tags, which are used to identify the exact
meta graph def to load.
The load
operation requires the session in which to restore the graph
definition and variables, the tags used to identify the meta graph def to
load and the location of the SavedModel.
Upon a load, the subset of variables and assets supplied as part of the specific
meta graph def, will be restored into the supplied session. The values of the
variables though will correspond to the saved values from the first meta graph
added to the SavedModel using add_meta_graph_and_variables(...)
in
builder.py
.
Typical usage:
...
builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(export_dir)
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
...
builder.add_meta_graph_and_variables(sess,
["foo-tag"],
signature_def_map=foo_signatures,
assets_collection=foo_assets)
...
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
...
builder.add_meta_graph(["bar-tag", "baz-tag"],
assets_collection=bar_baz_assets)
...
builder.save()
...
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
tf.compat.v1.saved_model.loader.load(sess, ["foo-tag"], export_dir)
...
Functions
load(...)
: Loads the model from a SavedModel as specified by tags. (deprecated)
maybe_saved_model_directory(...)
: Checks whether the provided export directory could contain a SavedModel.
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. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[[["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-06 UTC."],[],[],null,["# Module: tf.compat.v1.saved_model.loader\n\n\u003cbr /\u003e\n\nLoader functionality for SavedModel with hermetic, language-neutral exports.\n\nLoad and restore capability for a SavedModel, which may include multiple meta\ngraph defs. Each SavedModel is associated with a single checkpoint. Each meta\ngraph def is saved with one or more tags, which are used to identify the exact\nmeta graph def to load.\n\nThe `load` operation requires the session in which to restore the graph\ndefinition and variables, the tags used to identify the meta graph def to\nload and the location of the SavedModel.\n\nUpon a load, the subset of variables and assets supplied as part of the specific\nmeta graph def, will be restored into the supplied session. The values of the\nvariables though will correspond to the saved values from the first meta graph\nadded to the SavedModel using `add_meta_graph_and_variables(...)` in\n`builder.py`.\n\n#### Typical usage:\n\n ...\n builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(export_dir)\n\n with tf.compat.v1.Session(graph=tf.Graph()) as sess:\n ...\n builder.add_meta_graph_and_variables(sess,\n [\"foo-tag\"],\n signature_def_map=foo_signatures,\n assets_collection=foo_assets)\n ...\n\n with tf.compat.v1.Session(graph=tf.Graph()) as sess:\n ...\n builder.add_meta_graph([\"bar-tag\", \"baz-tag\"],\n assets_collection=bar_baz_assets)\n ...\n\n builder.save()\n\n ...\n with tf.compat.v1.Session(graph=tf.Graph()) as sess:\n tf.compat.v1.saved_model.loader.load(sess, [\"foo-tag\"], export_dir)\n ...\n\nFunctions\n---------\n\n[`load(...)`](../../../../tf/compat/v1/saved_model/load): Loads the model from a SavedModel as specified by tags. (deprecated)\n\n[`maybe_saved_model_directory(...)`](../../../../tf/compat/v1/saved_model/contains_saved_model): Checks whether the provided export directory could contain a SavedModel."]]