python - 你如何识别张量板图中的输入和输出名称,就像这篇文章所附图片中的这个一样?
问题描述
我使用 MobileNet_v1_1.0_224 tensorflow 模型进行对象检测。现在,我有我需要转换为 tflite 扩展名的自定义冻结图(.pb 文件),以便我可以将我的模型用于移动设备。
有人可以帮我识别这个张量板图中的输入和输出名称吗?我需要它们用作输入和输出参数,以将我的冻结图(.pb 文件)转换为 tensorflow lite(.tflite)文件
解决方案
您可以使用以下代码:
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
推荐阅读
- r - 拉普拉斯矩阵,解决电阻网格问题
- node.js - 使用 nodejs 阅读和发布 pdf
- c# - 使用 C# 将值写入 Excel
- sql - 在一列中创建一个具有默认值的空表
- python - Python sqlite 使用 json 更新
- r - 在R中的每一列中查找大于数字的元素的更简单的函数
- google-cloud-platform - Cloud Dataflow 的工作原理以及 Dataflow 作业的管理方式
- mysql - 使用 javascipt mysql 客户端执行 mysql 查询序列的正确方法
- python - Python对日期时间列进行计数并将其与NA进行比较
- c# - MapControl 是否有任何功能允许第二张地图与第一张地图保持一致?IE:缩放/位置