我使用此代码创建并加载单词嵌入:
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