tf.compat.v1.saved_model.load

Loads the model from a SavedModel as specified by tags. (deprecated)

Migrate to TF2

tf.compat.v1.saved_model.load or tf.compat.v1.saved_model.loader.load is not compatible with eager execution. Please use tf.saved_model.load instead to load your model. You can refer to the SavedModel guide for more information as well as "Importing SavedModels from TensorFlow 1.x" in the tf.saved_model.load docstring.

How to Map Arguments

TF1 Arg NameTF2 Arg NameNote
sessNot supported-
tagstags-
export_direxport_dir-
import_scopeNot supportedName scopes are not needed. By default, variables are associated with the loaded object and function names are deduped.
saver_kwargsNot supported-

Before & After Usage Example

Before:

with tf.compat.v1.Session(graph=tf.Graph()) as sess:
  tf.compat.v1.saved_model.loader.load(sess, ["foo-tag"], export_dir)

After:

model = tf.saved_model.load(export_dir, tags=["foo-tag"])

Description

Used in the notebooks

Used in the guide

sessThe TensorFlow session to restore the variables.
tagsSet of string tags to identify the required MetaGraphDef. These should correspond to the tags used when saving the variables using the SavedModel save() API.
export_dirDirectory in which the SavedModel protocol buffer and variables to be loaded are located.
import_scopeOptional string -- if specified, prepend this string followed by '/' to all loaded tensor names. This scope is applied to tensor instances loaded into the passed session, but it is not written through to the static MetaGraphDef protocol buffer that is returned.
**saver_kwargsOptional keyword arguments passed through to Saver.

The MetaGraphDef protocol buffer loaded in the provided session. This can be used to further extract signature-defs, collection-defs, etc.

RuntimeErrorMetaGraphDef associated with the tags cannot be found.