KeyedVectors\' 对象对于 gensim 4.1.2 没有属性 \'wv



我已经从gensim 3.8.3迁移到4.1.2,我正在使用这个

claim = [token for token in claim_text if token in w2v_model.wv.vocab]

reference = [token for token in ref_text if token in w2v_model.wv.vocab]

我不知道如何将w2v_model.wv.vocab替换为更新的属性,我得到了这个错误

KeyedVectors的对象没有属性"wv">请任何人提供帮助。

您只使用.wv属性从另一个更完整的算法模型中获取KeyedVectors对象,如完整的Word2Vec模型(其.wv属性中包含KeyedVectors(。

如果您已经只使用向量,则无需请求单词向量子组件。无论你要做什么,你都可以直接对KeyedVectors做。

但是,您也在使用已被替换的.vocab属性。有关更多详细信息,请参阅迁移常见问题解答:

https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#4-vocab-dict-becam-key_to_index-for-locking-up-a-key-integer-index-or-get_vect_attrandset_vecattr-for-other-per-key-attributes

(主要是:你可能只需要做in kv_modelin kv_model.key_to_index,而不是做in w2v_model.wv.vocab。(

KeyedVectors对象没有属性wv

在Gensim 4.0.0中,vocab属性已从KeyedVector中删除如果你寻找单词"maybe"的向量,而不是使用单词2vec.wv.['maybe'],请使用单词2Vec['maybe']。有关详细信息,请改用KeyedVector的.key_to_index dict、.index_to_key list以及方法.get_vecattr(key,attr(和.set_vecttr(key,attr,new_val(。

请参阅https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4

model.mv.similarity('woman', 'man') #instead of this use Below
model.similarity('woman', 'man')

参考:';KeyedVectors';对象没有属性';wv';/在Gensim 4.0.0 中,vocab属性已从KeyedVector中删除

最新更新