将 InceptionV3 pb 文件转换为 tflite
Convert InceptionV3 pb file to tflite
我正在尝试使用 TOCO 将 InceptionV3 模型从 pb 文件转换为 tflite 文件。我使用以下命令:
tflite_convert --output_file=/home/luca/Scrivania/prova.tflite --graph_def_file=/home/luca/Scrivania/inception_v3_2016_08_28_frozen.pb/inception_v3_2016_08_28_frozen.pb --input_arrays=input --output_arrays="InceptionV3/Predictions/Reshape_1:0"
但是我收到以下错误:
ValueError: Invalid tensors 'InceptionV3/Predictions/Reshape_1:0' were found.
我该如何解决?
此错误表示您提供的output_array
不正确。一般来说,InceptionV3 模型的输出数组是 InceptionV3/Predictions/Reshape
.
如果这不起作用,下一步是在 TensorBoard 中可视化您的 TensorFlow .pb
模型并查找输出数组。
如果你想知道“--output_arrays=”。在 frozen_inference_graph.pb 文件夹所在的位置创建一个 python 文件,然后将此代码粘贴到 py
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('tflite_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 ("output name = ")
print (data[len(data)-1])
print ("Input name = ")
file.seek ( 0 )
print (file.readline())
获得 运行 文件后,它将显示 input_arrays 和 output_arrays。
进一步的信息检查:How to convert .pb to TFLite format?
我正在尝试使用 TOCO 将 InceptionV3 模型从 pb 文件转换为 tflite 文件。我使用以下命令:
tflite_convert --output_file=/home/luca/Scrivania/prova.tflite --graph_def_file=/home/luca/Scrivania/inception_v3_2016_08_28_frozen.pb/inception_v3_2016_08_28_frozen.pb --input_arrays=input --output_arrays="InceptionV3/Predictions/Reshape_1:0"
但是我收到以下错误:
ValueError: Invalid tensors 'InceptionV3/Predictions/Reshape_1:0' were found.
我该如何解决?
此错误表示您提供的output_array
不正确。一般来说,InceptionV3 模型的输出数组是 InceptionV3/Predictions/Reshape
.
如果这不起作用,下一步是在 TensorBoard 中可视化您的 TensorFlow .pb
模型并查找输出数组。
如果你想知道“--output_arrays=”。在 frozen_inference_graph.pb 文件夹所在的位置创建一个 python 文件,然后将此代码粘贴到 py
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('tflite_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 ("output name = ")
print (data[len(data)-1])
print ("Input name = ")
file.seek ( 0 )
print (file.readline())
获得 运行 文件后,它将显示 input_arrays 和 output_arrays。
进一步的信息检查:How to convert .pb to TFLite format?