获取tensorflow lite中的量化激活

问题描述 投票:0回答:1

我试图在tf lite中获得中间特征映射值。

我使用解释器加载量化的mobilenet v1 224 tflite模型,并使用样本输入数据调用invoke。

网络输出似乎是正确的,但是当我查看get_tensor的输出作为中间输出(写成图像)时,其中一些看起来像是被后来的ops覆盖了(见示例图像)。

有没有办法为所有层检索正确的量化输出?

我建立了当前最新的TF 1.10.1

Conv2d_1_pointwise-Relu6_chan_3

Conv2d_2_pointwise-Relu6_chan_11

tensorflow-lite
1个回答
0
投票

我设法通过从原始冻结转换并使所有操作都在输出列表中来解决问题。

我看到有时边界是错误的,例如右侧在下图中有一列白色像素,但这是一个不同的问题。

Conv2d_1_pointwise-Relu6_chan_13

bazel run //tensorflow/contrib/lite/python:tflite_convert -- \
--output_file=toco_mobilenet_v1_1.0_224_quant.tflite \
--graph_def_file=mobilenet_v1_1.0_224_quant/mobilenet_v1_1.0_224_quant_frozen.pb \
--inference_type=QUANTIZED_UINT8 \
--mean_values=128 \
--std_dev_values=127 \
--input_arrays=input \
--output_arrays=MobilenetV1/MobilenetV1/Conv2d_0/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_1_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_1_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_2_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_2_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_3_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_3_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_4_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_4_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_5_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_5_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_6_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_6_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_7_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_7_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_8_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_8_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_9_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_9_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_10_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_10_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_11_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_11_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_12_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_12_pointwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_13_depthwise/Relu6,\
MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Relu6,\
MobilenetV1/Logits/AvgPool_1a/AvgPool,\
MobilenetV1/Logits/Conv2d_1c_1x1/BiasAdd,\
MobilenetV1/Logits/SpatialSqueeze,\
MobilenetV1/Predictions/Reshape_1
© www.soinside.com 2019 - 2024. All rights reserved.