尝试将我的TensorFlow模型导出到TLITE时遇到问题

在Google Colab上按照这个教程训练我的模型后,当我尝试运行model.export('image_classifier.tflite', 'image_labels.txt')时,显示如下错误:

---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)<ipython-input-37-4d5419f8b12d> in <module>()----> 1 model.export('image_classifier.tflite', 'image_labels.txt')1 frames/usr/local/lib/python3.6/dist-packages/tensorflow_examples/lite/model_customization/core/task/image_classifier.py in export(self, tflite_filename, label_filename, **kwargs)    185       else:    186         quantized = False--> 187       self._export_tflite(tflite_filename, label_filename, quantized)    188     else:    189       raise ValueError('Model Export Format %s is not supported currently.' %/usr/local/lib/python3.6/dist-packages/tensorflow_examples/lite/model_customization/core/task/classification_model.py in _export_tflite(self, tflite_filename, label_filename, quantized)    130       quantized: boolean, if True, save quantized model.    131     """--> 132     converter = tf.lite.TFLiteConverter.from_keras_model(self.model)    133     if quantized:    134       converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]AttributeError: type object 'TFLiteConverter' has no attribute 'from_keras_model

回答:

这个问题通过更新TensorFlow版本得以解决,我之前使用的是1.X版本,而TensorFlow在新版本中有了很大的变化。如果你在使用Google的Colab,版本仍然是1.X,很快将升级到2.0,所以建议你尝试以其他方式构建你的模型。

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中创建了一个多类分类项目。该项目可以对…

发表回复

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