TensorFlow导出
精华
小牛编辑
136浏览
2023-03-14
在这里,将重点关注和学习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')