【发布时间】:2021-04-09 10:24:24
【问题描述】:
我正在尝试将 tensorflow lite 文件添加到 Android Studio,但是当我添加它时,我收到一条错误消息,提示找不到元数据。我的 tensorflow 模型在我的笔记本电脑上远程工作,准确率达到 70%。我使用以下代码从 tensorflow 转换为 tensorflow lite。
import tensorflow as tf
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(units=1, input_shape=[1]),
tf.keras.layers.Dense(units=16, activation='relu'),
tf.keras.layers.Dense(units=1)
])
model.compile(optimizer='sgd', loss='mean_squared_error') # compile the model
model.fit(x=[-1, 0, 1], y=[-3, -1, 1], epochs=5) # train the model
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
Android Studio 上的错误消息 - “未找到元数据” 它提供了以下链接以添加元数据 https://www.tensorflow.org/lite/convert/metadata 我无法让给定的脚本工作
谁能向我解释我将如何调整此脚本以适应我的模型或任何替代解决方案?我花了数周时间寻找解决方案,但没有找到任何帮助,我们将不胜感激。
【问题讨论】:
标签: android-studio tensorflow tensorflow-lite