2017-10-12 171 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

相關問題