【发布时间】:2019-06-10 04:56:54
【问题描述】:
我使用预训练的 InceptionV3 模型进行了学习迁移,并保存了 h5 模型文件。在那之后,我能够做出预测。 现在,我想使用 TFLiteConverter.convert() 方法将 h5 模型转换为 tflite 文件,如下所示:
converter = lite.TFLiteConverter.from_keras_model_file('keras.model.h5')
tflite_model = converter.convert()
但我收到此错误:
File "from_saved_model.py", line 28, in <module>
tflite_model = converter.convert()
File "C:\Anaconda3\lib\site-packages\tensorflow\contrib\lite\python\lite.py", line 409, in convert
"invalid shape '{1}'.".format(_tensor_name(tensor), shape))
ValueError: None is only supported in the 1st dimension. Tensor 'input_1' has invalid shape '[None, None, None, 3]'
我在 Windows 10 64 位上运行 Anaconda Python 3.6.8。提前感谢您的帮助!
【问题讨论】:
-
在保存 keras 模型之前,能否确保 in_tensors 的形状正确(
[None, x, y, 3])? -
您的问题解决了吗?我面临着完全相同的问题
标签: tensorflow keras keras-layer tensorflow-lite