查看pb模型的节点

查看pb模型的节点
方法一:

import tensorflow as tf
import os
import cv2
#model_dir=frozen_inference_graph.pb"
# 读取并创建一个图graph来存放Google训练好的Inception_v3模型(函数)

def create_graph():
    with tf.gfile.FastGFile(model_dir, 'rb') as f:
        # 使用tf.GraphDef()定义一个空的Graph
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        # Imports the graph from graph_def into the current default Graph.
        tf.import_graph_def(graph_def,name='')

# 创建graph
create_graph()
tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
for tensor_name in tensor_name_list:
    print(tensor_name,'\n')

方法二:


import tensorflow as tf
import os
import cv2

with tf.Session() as sess:
    with open(model_dir, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        print('>>>打印输入节点的结构如下:\n', graph_def.node[0])
        print('*'*50,'\n')
        print('>>>打印输出节点的结构如下:\n',graph_def.node[-1])

用方法一查看
export_tflite_ssd_graph.py生成的lite.pb模型报错,用方法二可以

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值