【发布时间】:2019-10-22 07:31:01
【问题描述】:
我在下面的以下代码生成了常规的 tensorflow 模型,但是当我尝试将其转换为 tensorflow lite 时它不起作用,我遵循了以下文档。
https://www.tensorflow.org/tutorials/estimator/linear1 https://www.tensorflow.org/lite/guide/get_started
export_dir = "tmp"
serving_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(
tf.feature_column.make_parse_example_spec(feat_cols))
estimator.export_saved_model(export_dir, serving_input_fn)
# Convert the model.
converter = tf.lite.TFLiteConverter.from_saved_model("tmp/1571728920/saved_model.pb")
tflite_model = converter.convert()
错误信息
Traceback (most recent call last):
File "C:/Users/Dacorie Smith/PycharmProjects/JamaicaClassOneNotifableModels/ClassOneModels.py", line 208, in <module>
tflite_model = converter.convert()
File "C:\Users\Dacorie Smith\PycharmProjects\JamaicaClassOneNotifableModels\venv\lib\site-packages\tensorflow_core\lite\python\lite.py", line 400, in convert
raise ValueError("This converter can only convert a single "
ValueError: This converter can only convert a single ConcreteFunction. Converting multiple functions is under development.
文档摘录
TensorFlow Lite 转换器 TensorFlow Lite 转换器是一种工具 可作为 Python API 使用,可将经过训练的 TensorFlow 模型转换为 TensorFlow Lite 格式。它还可以引入优化,其中 在第 4 节“优化模型”中进行了介绍。
以下示例显示了正在转换的 TensorFlow SavedModel 转换成 TensorFlow Lite 格式:
将张量流导入为 tf
转换器 = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) tflite_model = converter.convert() open("converted_model.tflite", "wb").write(tflite_model)
【问题讨论】:
-
您收到的错误是什么?
-
你有什么错误吗?预期的行为是什么,你得到了什么?您是否还可以包含链接,或者最好是您所指的文档的摘录?
-
我将错误消息和更多详细信息添加到问题中。
-
您是否尝试过像这样设置保存的模型位置:converter = tf.lite.TFLiteConverter.from_saved_model("tmp/1571728920") 或像这样:converter = tf.lite.TFLiteConverter.from_saved_model(" ./tmp/1571728920")
-
我将错误消息和更多详细信息添加到问题@GuillermoGutiérrez
标签: python android tensorflow tensorflow-estimator tensorflow-lite