nunicodedecodeerror:'utf-8'编解码器无法在位置0:数据的意外末端解码byte 0xe3 我正在使用FastText.load_fastText_format()加载Google Colab中的FastText官方培训模型(300 DIM)。 这是我的代码。 model_path =“/content/drive/mydrive/idr/rakuten/

问题描述 投票:0回答:1

这是编码错误。

---------------------------------------------------------------------------

UnicodeDecodeError                        Traceback (most recent call last)

<ipython-input-7-61d7c85f09b2> in <module>()
      2 
      3 model_path = "/content/drive/MyDrive/IDR/rakuten/wikipedia_fastText/cc.ja.300.bin"
----> 4 model = FastText.load_fasttext_format(model_path)

2 frames

/usr/local/lib/python3.7/dist-packages/gensim/models/fasttext.py in _load_dict(self, file_handle, encoding)
    818                 word_bytes += char_byte
    819                 char_byte = file_handle.read(1)
--> 820             word = word_bytes.decode(encoding)
    821             count, _ = self.struct_unpack(file_handle, '@qb')
    822 

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 0: unexpected end of data

具体错误似乎是
unexpected end of data

您确定您已下载的

cc.ja.300.bin
文件是完整的未截断的长度,并且从下载的来源中匹配任何已声明的校验和的内容都没有损坏?
分开,
python unicode encoding utf-8 fasttext
1个回答
1
投票
类方法在Gensim

的当前版本中被删除,

load_facebook_model()

现在是首选的表单(尽管这不会考虑您的错误)。

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.