保存并加载word嵌入word2vec python

时间:2018-03-14 10:45:32

标签: python word2vec word-embedding

我使用此代码创建并加载单词嵌入:

model = Word2Vec(sentences,workers=4)
model.save(modelName)
model.wv.save_word2vec_format(vectorName+".bin",binary=True)

model = Word2Vec.load(modelName)
word_vectors = KeyedVectors.load_word2vec_format(vectorName+".bin", binary=True)

例如,为什么这段代码产生不同的输出?

print(model.wv.most_similar("woman"))
print(word_vectors.most_similar("woman"))

输出:

[('surprise', 0.529238224029541), ('cracked', 0.47902247309684753),..........
[(u'surprise', 0.529238224029541), (u'cracked', 0.47902247309684753),........

在第二个中,所有结果前面都有u

0 个答案:

没有答案