Traceback (most recent call last): File "/Users/siesta/Pycharm/TextClassifier/PCA_Word2vec.py", line 64, in <module> train_features[i][j] = np.mean(model[tokenizer.index_word[word_index]]) File "/Users/siesta/Pycharm/TextClassifier/lib/python3.9/site-packages/gensim/models/keyedvectors.py", line 403, in __getitem__ return self.get_vector(key_or_keys) File "/Users/siesta/Pycharm/TextClassifier/lib/python3.9/site-packages/gensim/models/keyedvectors.py", line 446, in get_vector index = self.get_index(key) File "/Users/siesta/Pycharm/TextClassifier/lib/python3.9/site-packages/gensim/models/keyedvectors.py", line 420, in get_index raise KeyError(f"Key '{key}' not present") KeyError: "Key 'of' not present"
时间: 2023-12-10 11:03:10 浏览: 170
linux 下 pip3 报错“ File “/usr/bin/pip3”, line 9, in from pip import mainImportError: canno”处理
5星 · 资源好评率100%
这是一个KeyError错误,提示'of'这个单词不存在于你的Word2Vec模型中。你需要检查你的Word2Vec模型是否已经训练好了,并且单词'of'是否在你的语料库中出现过。如果语料库中没有出现过'of'这个单词,那么你可以尝试将更大的语料库用于训练Word2Vec模型。如果语料库中有'of'这个单词,那么你需要检查一下你的代码,看看是否有任何错误。
阅读全文