尝试将我的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

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

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