查看tensorflow下保存的ckpt模型的节点
在华为云上面查到的,链接:https://bbs.huaweicloud.com/forum/thread-98878-1-1.html
记录一下。
import tensorflow as tf
outfile
=
"./node.txt"
model_path=r'D:\file\Panzi\logs_1\model.ckpt-4999'
with tf.Session() as sess:
tf.train.import_meta_graph(model_path
+
'.meta'
, clear_devices
=
True
)
graph_def
=
tf.get_default_graph().as_graph_def(add_shapes
=
True
)
node_list
=
[n.name
for
n
in
graph_def.node]
with
open
(outfile,
"w"
) as f:
for
node
in
node_list:
print
(
"node_name"
, node)
f.write(node
+
"\n"
)
路径换成自己的路径。
通过读取meta文件,获取所有节点名称,然后将其保存到txt中,在进行ckpt转pb时指定对应节点即可实现ckpt转pb。
加油!