【发布时间】:2020-03-13 18:27:51
【问题描述】:
我已经训练了一个模型并将其保存为 h5 文件。由于我想在我的 android 应用程序中使用它,我希望将它转换为 Colab 上的 tflite。这是我的代码:
import tensorflow as tf
model = tf.keras.models.load_model('Final_model.h5')
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
我得到的错误:
AttributeError: type object 'TFLiteConverter' has no attribute 'from_keras_model'
我该如何解决这个问题?
【问题讨论】:
-
您好,欢迎来到
StackOverflow!你的tensorflow是什么版本?您只需print(tf.__version__)即可轻松查看。 -
@SzymonMaszke 谢谢!我的版本是 1.15.0
标签: tensorflow machine-learning keras tensorflow2.0