【发布时间】:2018-10-29 17:34:43
【问题描述】:
我有两个使用 Keras 训练过的模型。这两个模型使用相同的架构(来自keras_applications.densenet 包的 DenseNet169 实现),但是它们各自具有不同数量的目标类(一种情况下为 80,另一种情况下为 200)。
将两个模型转换为 .pb 格式效果很好(推理性能相同)。我使用位于https://github.com/amir-abdi/keras_to_tensorflow 的
keras_to_tensorflow实用程序使用 TOCO 将两个模型转换为 .tflite 格式效果很好(同样,推理性能相同)。
在 TOCO 中使用量化将 80 类模型转换为 .tflite 效果相当好(前 3 名准确度下降
在 TOCO 中使用量化将 200-class 模型转换为 .tflite 偏离了轨道(前 3 位准确度下降了约 30%)。
我对两个模型都使用了与 TOCO 相同的命令行:
toco --graph_def_file frozen_graph.pb \
--output_file quantized_graph.tflite \
--inference_type FLOAT \
--inference_input_type FLOAT \
--output_format TFLITE \
--input_arrays input_1 \
--output_arrays output_node0 \
--quantize True
我的 tensorflow 版本是 1.11.0(通过 pip 在 macOS Mojave 上安装,尽管我也在用于训练的 Ubuntu 机器上尝试了相同的命令/环境,但结果相同)。
我完全不知道为什么一个模型的推理准确性会受到如此大的影响,而不是另一个模型。这适用于相同的两个架构/目标类组合的许多不同训练。我觉得我一定错过了什么,但我很困惑。
【问题讨论】:
标签: tensorflow machine-learning keras tensorflow-lite toco