Tensorflow 简明教程
TensorFlow - Exporting
在这里,我们着重于 TensorFlow 中的 MetaGraph 形成。这将有助于我们理解 TensorFlow 中的导出模块。MetaGraph 包含基本信息,该信息对于在先前训练的图中训练、执行评估或运行推理是必需的。
Here, we will focus on MetaGraph formation in TensorFlow. This will help us understand export module in TensorFlow. The MetaGraph contains the basic information, which is required to train, perform evaluation, or run inference on a previously trained graph.
以下是相同的代码片段-
Following is the code snippet for the same −
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. """
下面提到典型用法模型之一-
One of the typical usage model for the same is mentioned below −
# 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')