【发布时间】:2019-08-12 06:49:52
【问题描述】:
我正在尝试从 .pb 文件生成量化的 .tflite 模型。对于#process,我需要模型的“input_arrays”和“output_arrays”。
我尝试使用以下方法来识别输入数组和输出数组。但它们都不起作用。
方法一:
import tensorflow as tf
frozen='/output/freeze/frozen_inference_graph.pb'
gf = tf.GraphDef()
gf.ParseFromString(open(frozen,'rb').read())
[n.name + '=>' + n.op for n in gf.node if n.op in ('Softmax','Placeholder')]
[n.name + '=>' + n.op for n in gf.node if n.op in ( 'Softmax','Mul')]
方法二:
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('/output/freeze/frozen_inference_graph.pb','rb')
gf.ParseFromString(m_file.read())
for n in gf.node:
print( n.name )
tflite 转换查询:
import tensorflow as tf
graph_def_file = "new/barun/frozen_inference_graph.pb"
input_arrays = ['image_tensor']
output_arrays = ['BoxPredictor_5/ClassPredictor/act_quant/FakeQuantWithMinMaxVars']
converter = tf.lite.TFLiteConverter.from_frozen_graph(
graph_def_file, input_arrays, output_arrays,input_shapes={"image_tensor":[1,300,300,3]})
converter.inference_type = tf.lite.constants.QUANTIZED_UINT8
tflite_model = converter.convert()
open("frozen_inference_graph_fd2819_2.tflite", "wb").write(tflite_model)
如何找到.pb文件的input_array和output_array?
【问题讨论】:
标签: tensorflow tensorflow-lite