AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0. Use KeyedVector's .key_to_index dict, .index_to_key list, and methods .get_vecattr(key, attr) and .set_vecattr(key, attr, new_val) instead. See https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4
时间: 2023-06-15 22:08:30 浏览: 443
mdk_armcc_user_guide.pdf
这个错误是因为Gensim 4.0.0版本中的KeyedVector类不再具有vocab属性。相反,可以使用.key_to_index字典,.index_to_key列表以及.get_vecattr(key, attr)和.set_vecattr(key, attr, new_val)方法来替代。如果你使用的是旧版本的代码,请更新代码以适应新版本的Gensim。你可以参考这个链接:https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4。
阅读全文