Describe the bug
A clear and concise description of what the bug is.
tflite模型通过nncase转换为kmodel后输出结果变为随机数
To Reproduce
Command line or scripts to reproduce the behavior:
十分类任务,模型训练后测试集准确率0.99
保存模型model.save('model.h5')
将h5文件转换为tflite
import tensorflow as tf
modelparh ='model.h5'
model = tf.keras.models.load_model(modelparh)
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
'model.tflite'是输出的文件名
savepath = r'model.tflite'
open(savepath, "wb").write(tflite_model)
tflite转kmodel
python程序采用nncase使用说明中“”编译uint8量化tflite模型"示例
Expected behavior
A clear and concise description of what you expected to happen.
Origin model and code
If applicable, add orgin model and code to help explain your problem.
Environment (please complete the following information):
OS: [Win10]
nncase version [v1.7.0]
DL Framework [keras2.4.3,TensorFlow 2.4.0]
python3.7
Additional context
Add any other context about the problem here.
问题解决方法:不使用ptq PC端推理结果正确,准确率为0.99
可能原因:converter = tf.lite.TFLiteConverter.from_keras_model(model)这一步已经进行了量化,(源h5模型大小为5814kb,tflite模型大小为1922kb)nncase再次量化造成结果出错
但k210推理仍为随机数
Describe the bug A clear and concise description of what the bug is. tflite模型通过nncase转换为kmodel后输出结果变为随机数 To Reproduce Command line or scripts to reproduce the behavior: 十分类任务,模型训练后测试集准确率0.99 保存模型model.save('model.h5') 将h5文件转换为tflite import tensorflow as tf modelparh ='model.h5' model = tf.keras.models.load_model(modelparh) converter = tf.lite.TFLiteConverter.from_keras_model(model) tflite_model = converter.convert()
'model.tflite'是输出的文件名
savepath = r'model.tflite' open(savepath, "wb").write(tflite_model) tflite转kmodel python程序采用nncase使用说明中“”编译uint8量化tflite模型"示例 Expected behavior A clear and concise description of what you expected to happen.
Origin model and code If applicable, add orgin model and code to help explain your problem.
Environment (please complete the following information):
Additional context Add any other context about the problem here. 问题解决方法:不使用ptq PC端推理结果正确,准确率为0.99 可能原因:converter = tf.lite.TFLiteConverter.from_keras_model(model)这一步已经进行了量化,(源h5模型大小为5814kb,tflite模型大小为1922kb)nncase再次量化造成结果出错 但k210推理仍为随机数