【发布时间】:2018-06-13 14:30:54
【问题描述】:
我尝试加载 GoogleNews-vectors-negative300.bin 并尝试 predict_output_word 方法,
我测试了三种方式,但都失败了,每种方式的代码和错误如下所示。
import gensim
from gensim.models import Word2Vec
- 第一个:
我第一次使用这一行:
model=Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin',binary=True)
print(model.wv.predict_output_word(['king','man'],topn=10))
错误:
DeprecationWarning: Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead.
- 第二个:
然后我尝试了:
model = gensim.models.KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin',binary=True)
print(model.wv.predict_output_word(['king','man'],topn=10))
错误:
AttributeError: 'Word2VecKeyedVectors' object has no attribute 'predict_output_word'
- 第三个: 模型 = gensim.models.Word2Vec.load('GoogleNews-vectors-negative300.bin') print(model.wv.predict_output_word(['king','man'],topn=10))
错误: _pickle.UnpicklingError: 无效的加载键,'3'。
我在
阅读了文档https://radimrehurek.com/gensim/models/word2vec.html
但仍然不知道 predict_output_word 所在的命名空间。
有人可以帮忙吗?
谢谢。
【问题讨论】:
标签: word2vec