【发布时间】:2020-01-21 18:37:52
【问题描述】:
当我尝试运行model.export('image_classifier.tflite', 'image_labels.txt') 时,在 GoogleColab 上训练我的模型后,this tutorial 向我展示了
---------------------------------------------------------------------------
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?您更有可能使用的是 TF 的 1.x 版本
-
谢谢,我使用的是你所说的版本 1,这解决了我的问题 :)
标签: python tensorflow artificial-intelligence tensorflow-lite