【发布时间】:2020-10-03 03:00:07
【问题描述】:
我想在 android studio 中使用我的 keras 训练模型。我在互联网上获得了此代码,以将我的代码从 keras 转换为 tensorflow-lite。但是当我尝试代码时,我得到了这个错误:
OSError: SavedModel file does not exist at: C:\Users\Munib\New folder/{saved_model.pbtxt|saved_model.pb}
我从 keras 转换到 tensorflow-lite 时使用的代码:
import tensorflow as tf
# Converting a SavedModel to a TensorFlow Lite model.
saved_model_dir = r"C:\Users\Munib\New folder"
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()
# Converting a tf.Keras model to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
# Converting ConcreteFunctions to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_concrete_functions([func])
tflite_model = converter.convert()
【问题讨论】:
-
你能解决这个问题吗? ,我也卡住了。
标签: python tensorflow keras tensorflow-lite