2017-10-12 173 views

回答

0

我不确定您是否使用gensim或其他工具创建了word2vec模型,但是如果正确理解您的问题,则只需使用gensim加载word2vec模型。这是通过以下方式进行:

import gensim 
w2v_file = codecs.open(WORD2VEC_PATH, encoding='utf-8') 
model = gensim.models.KeyedVectors.load_word2vec_format(w2v_file, binary=True) # or binary=False if the model is not compressed 

但是,如果你想要做的是培养word2vec使用纯gensim这里从头模型(即从原始文本)是一个tutorial on how to train word2vec model using gensim

+0

谢谢,这正是我正在寻找的。 –

+0

您能否提供示例w2v_file或帮助我生成该格式?我将这个单词和它的向量放在一个由空格和单词分隔的行中,并用行分隔。谢谢。 @sophros –

+0

你有没有尝试过以下方法?'from gensim.models import word2vec model = word2vec.Word2Vec.load_word2vec_format('path/to/GoogleNews-vectors-negative300.bin',binary = False)' 重要的部分是'binary = False'。 – sophros

相关问题