网络编程
位置:首页>> 网络编程>> Python编程>> tensorflow 实现打印pb模型的所有节点

tensorflow 实现打印pb模型的所有节点

作者:coocoky  发布时间:2022-09-28 22:37:33 

标签:tensorflow,打印,pb模型,节点

只有pd模型文件, 打印所有节点


from tensorflow.python.framework import tensor_util
from google.protobuf import text_format
import tensorflow as tf
from tensorflow.python.platform import gfile
from tensorflow.python.framework import tensor_util

GRAPH_PB_PATH = 'models/frozen_person_graph.pb' #path to your .pb file
with tf.Session() as sess:
print("load graph")
with gfile.FastGFile(GRAPH_PB_PATH,'rb') as f:
graph_def = tf.GraphDef()
 # Note: one of the following two lines work if required libraries are available
#text_format.Merge(f.read(), graph_def)
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
for i,n in enumerate(graph_def.node):
print("Name of the node - %s" % n.name)

来源:https://blog.csdn.net/cooco369/article/details/82999172

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com