A SavedModel holds one or more
MetaGraphDefs, each a graph together with what is needed to run it: tags
that pick it out, the signatures a caller uses, and how to restore its variables. These
messages are from TensorFlow’s meta_graph.proto and
saver.proto, with Any from Protocol Buffers’ own
any.proto (all proto3). Maps are written as lists of entry messages, as
the Protocol Buffers
reference describes.
MetaGraphDef
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | meta_info_def | MetaInfoDef | LEN | Tags, versions and the ops the graph uses. |
| 2 | graph_def | GraphDef | LEN | The graph, with its function library. |
| 3 | saver_def | SaverDef | LEN | How to save and restore the variables. |
| 4 | collection_def | map<string, CollectionDef> | LEN, one per entry | Named collections, a TensorFlow 1 feature. |
| 5 | signature_def | map<string, SignatureDef> | LEN, one per entry | Named signatures, such as serving_default. |
| 6 | asset_file_def | repeated AssetFileDef | LEN, one per asset | Asset files the graph uses. |
| 7 | object_graph_def | SavedObjectGraph | LEN | The saved Python objects and their functions, in TensorFlow 2. The explorer does not include this message and shows it by number. |
MetaGraphDef.MetaInfoDef
Metadata: the meta graph’s tags and the TensorFlow version that wrote it. The explorer shows the tags and the version of each meta graph.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | meta_graph_version | string | LEN | A version the user chose. |
| 2 | stripped_op_list | OpList | LEN | The definitions of the ops the graph uses. |
| 3 | any_info | Any | LEN | Extra information of any type. |
| 4 | tags | repeated string | LEN, one per tag | Tags that pick this meta graph out, such as serve or train. |
| 5 | tensorflow_version | string | LEN | The TensorFlow version that wrote it. |
| 6 | tensorflow_git_version | string | LEN | Its git version. |
| 7 | stripped_default_attrs | bool | VARINT | Whether attributes at their default values were left out of the nodes. |
| 8 | function_aliases | map<string, string> | LEN, one per entry | Aliases for functions. |
MetaGraphDef.MetaInfoDef.FunctionAliasesEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The key. |
| 2 | value | string | LEN | The value. |
MetaGraphDef.CollectionDefEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The collection’s name. |
| 2 | value | CollectionDef | LEN | Its contents. |
MetaGraphDef.SignatureDefEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The signature’s name, such as serving_default. |
| 2 | value | SignatureDef | LEN | Its definition. |
CollectionDef
A collection: a list of one kind. Fields 1 to 5 form a oneof.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | node_list | NodeList | LEN | Node names. |
| 2 | bytes_list | BytesList | LEN | Byte strings. |
| 3 | int64_list | Int64List | LEN | Integers. |
| 4 | float_list | FloatList | LEN | Floats. |
| 5 | any_list | AnyList | LEN | Any messages. |
CollectionDef.NodeList
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | value | repeated string | LEN, one per name | The node names. |
CollectionDef.BytesList
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | value | repeated bytes | LEN, one per value | The values, often serialised messages. |
CollectionDef.Int64List
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | value | repeated int64, packed | LEN | The values. |
CollectionDef.FloatList
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | value | repeated float, packed | LEN | The values. |
CollectionDef.AnyList
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | value | repeated Any | LEN, one per value | The values. |
SignatureDef
A signature: the named inputs a caller feeds and the named outputs it fetches. The explorer lists every signature of every meta graph with its inputs and outputs.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | inputs | map<string, TensorInfo> | LEN, one per entry | Inputs by name. |
| 2 | outputs | map<string, TensorInfo> | LEN, one per entry | Outputs by name. |
| 3 | method_name | string | LEN | Deprecated: the kind of call, such as tensorflow/serving/predict. |
| 4 | defaults | map<string, TensorProto> | LEN, one per entry | Default values for inputs. |
SignatureDef.InputsEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The input’s name, as a caller gives it. |
| 2 | value | TensorInfo | LEN | The graph tensor it feeds. |
SignatureDef.OutputsEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The output’s name. |
| 2 | value | TensorInfo | LEN | The graph tensor it comes from. |
SignatureDef.DefaultsEntry
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | key | string | LEN | The input’s name. |
| 2 | value | TensorProto | LEN | Its default value. |
TensorInfo
Which tensor of the graph a signature input or output is, with its type and shape.
Fields 1, 4 and 5 form the oneof encoding.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | name | string | LEN | The tensor’s name in the graph, as node:output, such as serving_default_x:0. |
| 4 | coo_sparse | CooSparse | LEN | A sparse tensor’s three tensors. |
| 5 | composite_tensor | CompositeTensor | LEN | A composite tensor. |
| 2 | dtype | DataType | VARINT | The data type. |
| 3 | tensor_shape | TensorShapeProto | LEN | The shape; −1 for a size not known, such as the batch. |
TensorInfo.CooSparse
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | values_tensor_name | string | LEN | The tensor of values. |
| 2 | indices_tensor_name | string | LEN | The tensor of indices. |
| 3 | dense_shape_tensor_name | string | LEN | The tensor of the dense shape. |
TensorInfo.CompositeTensor
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | type_spec | TypeSpecProto | LEN | The type spec. The explorer does not include this message and shows it by number. |
| 2 | components | repeated TensorInfo | LEN, one per component | The component tensors. |
AssetFileDef
An asset file, such as a vocabulary, and the tensor that receives its path when the model is loaded.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | tensor_info | TensorInfo | LEN | The tensor fed the file’s path. |
| 2 | filename | string | LEN | The file’s name in the assets folder. |
SaverDef
How the variables are saved to and restored from the variables folder.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | filename_tensor_name | string | LEN | The tensor that takes the checkpoint’s file name. |
| 2 | save_tensor_name | string | LEN | The op that saves. |
| 3 | restore_op_name | string | LEN | The op that restores. |
| 4 | max_to_keep | int32 | VARINT | How many checkpoints to keep. |
| 5 | sharded | bool | VARINT | Whether to save in shards. |
| 6 | keep_checkpoint_every_n_hours | float | I32 | Keep one checkpoint every so many hours. |
| 7 | version | CheckpointFormatVersion | VARINT | The checkpoint format: LEGACY (0), V1 (1) or V2 (2). |
Any
Any message, named by a type URL; Protocol Buffers’ own
google.protobuf.Any.
| Field | Name | Type | Wire type | Meaning |
|---|---|---|---|---|
| 1 | type_url | string | LEN | The message type, such as type.googleapis.com/tensorflow.Foo. |
| 2 | value | bytes | LEN | The message, encoded. |