首页 > 解决方案 > 你如何识别张量板图中的输入和输出名称,就像这篇文章所附图片中的这个一样?

问题描述

我使用 MobileNet_v1_1.0_224 tensorflow 模型进行对象检测。现在,我有我需要转换为 tflite 扩展名的自定义冻结图(.pb 文件),以便我可以将我的模型用于移动设备。

有人可以帮我识别这个张量板图中的输入和输出名称吗?我需要它们用作输入和输出参数,以将我的冻结图(.pb 文件)转换为 tensorflow lite(.tflite)文件

来自张量板的图表

同一张图

标签: pythontensorflowdeep-learningtensorboardtensorflow-lite

解决方案


您可以使用以下代码:

import tensorflow as tf
gf = tf.GraphDef()   
m_file = open('frozen_inference_graph.pb','rb')
gf.ParseFromString(m_file.read())

with open('somefile.txt', 'a') as the_file:
    for n in gf.node:
        the_file.write(n.name+'\n')

file = open('somefile.txt','r')
data = file.readlines()
print ("\noutput name = ")
print (data[len(data)-1])

print ("Input name = ")
file.seek ( 0 )
print (file.readline())

就我而言,我有

output name: SemanticPredictions
input name: ImageTensor

推荐阅读