我使用TensorFlow的估算器构建了分类模型,保存模型后,在将其转换为TensorFlow Lite时出现了错误

模型保存时没有错误

tflite_model = converter.convert()

当我执行这一行时,我得到了以下异常

  ConverterError                            Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/convert.py in toco_convert_protos(model_flags_str, toco_flags_str, input_data_str, debug_info_str, enable_mlir_converter)
    295       return model_str
    296     except Exception as e:
--> 297       raise ConverterError(str(e))
    298
    299   if distutils.spawn.find_executable(_toco_from_proto_bin) is None:
ConverterError: <unknown>:0: error: loc("head/predictions/str_classes"): 'tf.AsString' op is neither a custom op nor a flex op
<unknown>:0: error: failed while converting: 'main': Some ops in the model are custom ops, See instructions to implement custom ops: https://www.tensorflow.org/lite/guide/ops_custom Custom ops: AsString
Details:    tf.AsString(tensor<?x1xi64>) -> (tensor<?x1x!tf.string>) : {device = "", fill = "", precision = -1 : i64, scientific = false, shortest = false, width = -1 : i64}

我尝试使用TensorFlow的每日版本,但错误仍然存在。我正在尝试使用TensorFlow构建一个分类模型,然后我想将其转换为TensorFlow Lite以用于Android应用程序。如果有其他不需要转换为TensorFlow Lite的方法,那也是可以接受的


回答:

TFLite产品中的TF选择选项目前还不支持tf.AsString操作。对于这种情况,您可以在这里报告功能请求。

上述操作未包含在TF选择的允许列表中,可以通过添加类似于这个提交的相关代码来修复。如果您能创建这样的拉取请求,那就太好了。


修复已提交,AsString操作将从明天的TensorFlow每日版本开始通过TF选择选项可用。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注