Gensim预测输出字功能语法

时间:2019-02-12 06:43:41

标签: gensim

您如何使用Gensim预测输出字功能?

model = KeyedVectors.load_word2vec_format('./GoogleNews-vectors-negative300.bin', binary=True)

model.predict_output_word(['Hi', 'how', 'you'], topn=10)

AttributeError: 'Word2VecKeyedVectors' object has no attribute 'predict_output_word'

我尝试了不推荐使用的Word2Vec.load_word2vec_format('./ GoogleNews-vectors-negative300.bin',binary = True)。

1 个答案:

答案 0 :(得分:2)

GoogleNews-vectors-negative300.bin之类的文件仅包含单词向量,而不包含用于训练的完整模型。因此,在这种情况下无法使用predict_output_word。如果您本来可以训练一个完整的模型并用model.save()保存,那么方法predict_output_word就可以使用。