tensorflow查看pb,lite模型函数总结

想要调用他人保存的pb或lite模型时往往需要查看模型结构,输入节点类型等,总结一些方法

首先考虑使用Netron看图,还有命令行中使用命令的方式,这里总结利用python

.Lite模型

interpreter = tf.contrib.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()

# Get input and output tensors.
input_details = interpreter.get_input_details()
print(str(input_details))
output_details = interpreter.get_output_details()
print(str(output_details))

.pb模型

使用tensorboard

inception_graph_def_file = '/home/huang/huang/model/inception/classify_image_graph_def.pb'
with tf.Session() as sess:
    #创建一个图来存放google训练好的模型
    with tf.gfile.GFile(inception_graph_def_file, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        tf.import_graph_def(graph_def, name='')
    #保存图的结构
    writer = tf.su

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值