【发布时间】:2022-04-23 13:13:22
【问题描述】:
AttributeError Traceback(最近一次调用最后一次) ~/Desktop/implimentaion/train.py 在 31 使用_w2v = 真 32 ---> 33 train_df, embeddings = make_w2v_embeddings(train_df, embedding_dim=embedding_dim, empty_w2v=not use_w2v) 34 35 # 拆分训练验证
~/Desktop/implimentaion/util.py in make_w2v_embeddings(df, embedding_dim, empty_w2v) 90 91 # 如果 word2vec 模型中缺少一个单词。 ---> 92 如果单词不在 word2vec.vocab 中: 93 如果单词不在 vocabs_not_w2v 中: 94 词汇_not_w2v_cnt += 1
~/opt/anaconda3/lib/python3.8/site-packages/gensim/models/keyedvectors.py in vocab(self) 第643章 第644章 --> 645 引发属性错误( 646 “词汇属性已从 Gensim 4.0.0 中的 KeyedVector 中删除。\n” 647 “使用 KeyedVector 的 .key_to_index 字典、.index_to_key 列表和方法”
AttributeError:词汇属性已从 Gensim 4.0.0 中的 KeyedVector 中删除。 改用 KeyedVector 的 .key_to_index 字典、.index_to_key 列表和方法 .get_vecattr(key, attr) 和 .set_vecattr(key, attr, new_val)。 见https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4
【问题讨论】:
-
请参考为什么这个问题应该关闭这个问题:stackoverflow.com/help/how-to-ask
-
能否请您描述一下,为什么会出现此错误?