gpt4 book ai didi

python - 尝试将我的 Tensorflow 模型导出到 T LITE 时出现问题

转载 作者:太空宇宙 更新时间:2023-11-03 19:50:58 26 4
gpt4 key购买 nike

在 GoogleColab 上训练我的模型之后 this tutorial当我尝试运行 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所以尝试用另一种方式构建你的模型。

关于python - 尝试将我的 Tensorflow 模型导出到 T LITE 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59847274/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com