|View source on GitHub|
SavedModel protocol buffer and saves variables and assets.
Compat aliases for migration
See Migration guide for more details.
tf.compat.v1.saved_model.Builder( export_dir )
SavedModelBuilder class provides the functionality to build a
SavedModel protocol buffer. Specifically, this allows multiple meta
graphs to be saved as part of a single language-neutral
while sharing variables and assets.
To build a SavedModel, the first meta graph must be saved with variables. Subsequent meta graphs will simply be saved with their graph definitions. If assets need to be saved and written or copied to disk, they can be provided when the meta graph def is added. If multiple meta graph defs are associated an asset of the same name, only the first version is retained.
Each meta graph added to the SavedModel must be annotated with tags. The tags provide a means to identify the specific meta graph to load and restore, along with the shared set of variables and assets.
Typical usage for the
... builder = tf.compat.v1.saved_model.Builder(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"]) ... builder.save()