【问题标题】:Problem trying to export my Tensor Flow model to TLITE尝试将我的 Tensorflow 模型导出到 TFLITE 时出现问题
【发布时间】: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


【解决方案1】:

更新Tensorflow版本问题解决了,我用的是1.X版本,新版本的TensorFlow变化很大,如果你用的是GOOGLE的COLAB,版本仍然是1.X,很快就会变成2所以尝试用另一种方式构建你的模型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    • 1970-01-01
    • 2019-07-12
    相关资源
    最近更新 更多