Introduction
SavedModel is the standard way to save a complete model in
TensorFlow. It is a folder, not a single file:
a saved_model.pb file describing the model’s computation, beside folders for
its weights and any extra files it needs. Because it holds the graph as well as the
weights, it can be loaded and run without the Python code that built the model, which is
how TensorFlow Serving, the TensorFlow Lite converter and TensorFlow.js take models in.
Structure
/saved_model.pb the graphs and their signatures, a Protocol Buffers messagefile/variables/variables.indexandvariables.data-00000-of-00001shardsfolder/assets/ extra files such as vocabulariesfolder/fingerprint.pb hashes that identify the model, in newer versionsfile
saved_model.pb is a binary
Protocol Buffers message of type
SavedModel, holding one or more MetaGraphDefs. Each has a
graph of operations, tags such as serve, and named
signatures, usually serving_default, that give the inputs
and outputs a caller should use. A text version of the same message may be saved as
saved_model.pbtxt. The weights are stored in the same layout as a
TensorFlow checkpoint.
Older TensorFlow 1 code also wrote a frozen graph: a single
.pb file holding a GraphDef with the weights folded in as
constants.
Also used for
Links
Software
- TensorFlow (Windows, macOS, Linux)
- TensorFlow Serving (Linux)
- Netron, a viewer that draws the graph (Windows, macOS, Linux, web)
Developers
- TensorFlow, Python, with
tf.saved_model.saveandtf.saved_model.load, and a C++ loader
Reference
- Using the SavedModel format, TensorFlow guide