在这里,我们将专注于 TensorFlow 中的 MetaGraph 形成。这将帮助我们理解 TensorFlow 中的导出模块。MetaGraph 包含了训练、执行评估或在先前训练过的图上运行推断所需的基本信息。
以下是相应的代码片段 −
def export_meta_graph(filename = None, collection_list = None, as_text = False):
"""this code writes `MetaGraphDef` to save_path/filename.
Arguments:
filename: Optional meta_graph filename including the path. collection_list:
List of string keys to collect. as_text: If `True`,
writes the meta_graph as an ASCII proto.
Returns:
A `MetaGraphDef` proto. """
其中一个典型的用法模型如下所述 −
# Build the model ...
with tf.Session() as sess:
# Use the model ...
# Export the model to /tmp/my-model.meta.
meta_graph_def = tf.train.export_meta_graph(filename = '/tmp/my-model.meta')