分享

成功解决AttributeError: 'Word2Vec' object has no attribute 'index2word'

 处女座的程序猿 2021-09-28

成功解决AttributeError: 'Word2Vec' object has no attribute 'index2word'


解决问题

AttributeError: 'Word2Vec' object has no attribute 'index2word'

解决思路

from gensim.models import word2vec
python的Gensim包升级版本后,里面很多调用方法已经发生了改变,所以要查看API,对于以前使用的方法,查看升级后,改进的调用方法。

解决方法


model.index2word
改为
model.wv.index2word

哈哈,大功告成!

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章