【发布时间】:2019-09-09 11:04:06
【问题描述】:
我有张量流模型的 .meta 和 .ckpt 文件。我想知道确切的输入和输出节点名称,但我通过关注this 获得了节点名称列表。
当我有一个冻结的 protobuf 模型时,我使用以下代码获取输入节点名称和输出节点名称作为列表的开始和结束:
import tensorflow as tf
from tensorflow.python.platform import gfile
GRAPH_PB_PATH = 'frozen_model.pb'
with tf.Session() as sess:
print("load graph")
with gfile.FastGFile(GRAPH_PB_PATH,'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
sess.graph.as_default()
tf.import_graph_def(graph_def, name='')
graph_nodes=[n for n in graph_def.node]
names = []
for t in graph_nodes:
names.append(t.name)
print(names)
我可以为 .ckpt 或 .meta 文件做类似的事情吗?
【问题讨论】:
标签: python tensorflow deep-learning