我遵循TenslorFlow TFlite基本文本分类教程,但第三个导入行抛出错误:
from tensorflow_examples.lite.model_maker.core.data_util import image_dataloader
ModuleNotFoundError: No module named 'official.nlp.bert'
我用pip install tensorflow
安装了TensorFlow,用pip install -q tflite-model-maker
安装了tflite model maker。
我已经安装了pip install tf-models-official
的所有官方模型。
我可以在官方模型GitHub上看到BERT模型,所以它应该在那里。
如何安装bert
模型?
完全错误:
Traceback (most recent call last):
File "...Downloadstf_setup.py", line 6, in <module>
from tflite_model_maker import model_spec
File "...AppDataLocalProgramsPythonPython310libsite-packagestflite_model_maker__init__.py", line 16, in <module>
from tensorflow_examples.lite.model_maker.core.data_util import image_dataloader
File "...AppDataLocalProgramsPythonPython310libsite-packagestensorflow_exampleslitemodel_maker__init__.py", line 17, in <module>
from tensorflow_examples.lite.model_maker.core.data_util import text_dataloader
File "...AppDataLocalProgramsPythonPython310libsite-packagestensorflow_exampleslitemodel_makercoredata_utiltext_dataloader.py", line 31, in <module>
from tensorflow_examples.lite.model_maker.core.task import model_spec as ms
File "...AppDataLocalProgramsPythonPython310libsite-packagestensorflow_exampleslitemodel_makercoretaskmodel_spec.py", line 37, in <module>
from official.nlp.bert import configs as bert_configs
ModuleNotFoundError: No module named 'official.nlp.bert'
你的Python版本是什么?我在使用Python 3.10时遇到了完全相同的错误。我的小模型制造者是0.1。x版本,尽管我试图安装最新的0.4.0。我想更新它,但我得到了更多关于"没有匹配的分布"的错误。对于tflite-model-maker和tflite-support。在我安装并更改我的Python解释器(我使用PyCharm)到Python 3.9.13并重新安装tflite-model-maker后,错误消失了。