DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv._

from gensim.models import word2vec

model = word2vec.Word2Vec.load("hoge.model")
vec = model["queen"]
print(len(vec.tolist()))
#运行出现错误
DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).
#解决方法
from gensim.models import Word2Vec

model = Word2Vec.load("hoge.model")
vec = model.wv['queen']
print(len(vec.tolist()))
加入wv就可以解决问题了。
感觉有用给博主点赞加收藏哦

猜你喜欢

转载自blog.csdn.net/weixin_45631815/article/details/109722878
今日推荐