在Tensorflow 2.0中从.hdf5转换为.tflite时,为什么会出现“ ValueError:未知层:KerasLayer”?

我使用来自Tensorflow集线器的预训练模型训练数据,这使我的val_acc大大提高。我将模型另存为.hdf5文件,并打算将其转换为.tflite,以便可以导入到我的android应用程序中。这是我在转换时使用的代码:

from tensorflow_core.lite.python.lite import TFLiteConverter
model_path = 'C:/Users/1/Desktop/data_sets/86%.hdf5'
converter = TFLiteConverter.from_keras_model_file(model_path)
tflite_model = converter.convert()
open("converted_model.tflite","wb").write(tflite_model)

它输出“ ValueError:未知图层:KerasLayer”

我正在使用tf版本2.0。 这就是我保存模型的方式。下面的代码在回调中。

ModelCheckpoint(filepath=data_dir + '/weights.hdf5',monitor='val_accuracy',verbose=1,save_best_only=True,save_weights_only=False,mode='auto',period=1)

photot of error message

cafeblue 回答:在Tensorflow 2.0中从.hdf5转换为.tflite时,为什么会出现“ ValueError:未知层:KerasLayer”?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3168158.html

大家都在问