查看tensorflow的pb文件里每一层的结构名

import tensorflow as tf
import os
model_dir = './'
model_name = '*.pb'
#这里填文件名
# model_name = 'frozen_graph.pb'

def create_graph():
    with tf.gfile.FastGFile(os.path.join(
            model_dir, model_name), 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        tf.import_graph_def(graph_def, name='')

#FusedBatchNormV3
create_graph()
tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
with open("kerasyolofire.txt", "w", encoding='utf-8') as f:
    for tensor_name in tensor_name_list:
        print(tensor_name, '\n')
        f.write(str(tensor_name)+'\n')


猜你喜欢

转载自blog.csdn.net/weixin_43850171/article/details/118146046
今日推荐