espressif / esp-dl

Espressif deep-learning library for AIoT applications
MIT License
548 stars 118 forks source link

用量化工具时遇到了current model is not supported by esp-dl的错误 (AIV-409) #58

Closed xiao-mb closed 2 years ago

xiao-mb commented 3 years ago

Generating the quantization table: MatMul is not supported on esp-dl yet Softmax is not supported on esp-dl yet Traceback (most recent call last): File "example.py", line 40, in calib.generate_quantization_table(model_proto, calib_dataset, pickle_file_path) File "calibrator.py", line 320, in calibrator.Calibrator.generate_quantization_table File "calibrator.py", line 209, in calibrator.Calibrator.generate_output_model File "calibrator.py", line 204, in calibrator.Calibrator.check_model ValueError: current model is not supported by esp-dl 用量化工具时遇到了以上错误,要如何修改?

Auroragan commented 3 years ago

因为 esp-dl 的 API 暂不支持 matmul 和 softmax, 所以 calibrator 暂不能接受这个模型

xiao-mb commented 3 years ago

看例子里的Dense层被优化成Gemm,我模型里的Dense还是matmul,没有被优化为Gemm,这是为什么?

Auroragan commented 3 years ago

你这一层没有 bias 吗?

xiao-mb commented 3 years ago

有的

Auroragan commented 3 years ago

能把模型图发出来看一下吗?

Auroragan commented 3 years ago

试试把 optimizer.py https://github.com/espressif/esp-dl/blob/8a5be0973686e8ae16e19a345025a954b5cdc31e/tools/quantization_tool/optimizer.py#L137

if not dim[0].dim_param:
    dim[0].dim_param = 'N'

改成 固定的batch size:

dim[0].dim_param = '20'

看一下能不能 fuse 成功

xiao-mb commented 3 years ago

order_model_tf2_optimized onnx 还是不行

Auroragan commented 3 years ago

dim[0].dim_param = '' dim[0].dim_value = 20

改成这样呢?

xiao-mb commented 3 years ago

可以了。能生成模型文件的版本麻烦尽快更新下,谢谢!

Auroragan commented 3 years ago

我们 API 将会有所改动, 能生成模型文件的版本将在之后与 API 一起更新

xiao-mb commented 3 years ago

dim[0].dim_param = '' dim[0].dim_value = 20

改成这样呢?

batch size 的大小有什么讲究吗,把网络移植到s3上后,识别不正确。评估的准确率如下:

Evaluating the performance on esp32s3: accuracy of int16 model is: 0.996094 accuracy of fp32 model is: 0.996094 把同张图片导出,在PC上测试,识别正确。在S3上,不同的图片大多数会预测出同一个值,而且不正确。这个问题应该从哪些方面来定位原因?