2016-09-17 210 views

回答

3

只是装载

import gensim 

# Load pre-trained Word2Vec model. 
model = gensim.models.Word2Vec.load("modelName.model") 

现在你可以训练模型如常。如果你想能够保存它并重新训练多次,这里是你应该做的

model.train(//insert proper parameters here//) 
""" 
If you don't plan to train the model any further, calling 
init_sims will make the model much more memory-efficient 
If `replace` is set, forget the original vectors and only keep the normalized 
ones = saves lots of memory! 
replace=True if you want to reuse the model 
""" 
model.init_sims(replace=True) 

# save the model for later use 
# for loading, call Word2Vec.load() 

model.save("modelName.model") 
+0

我得到这个错误:文件“C:\ ... \ Python \ Python35 \ lib \ site- packages \ gensim \ utils.py“,第911行,在unpickle 返回_pickle.loads(f.read()) _pickle.UnpicklingError:无效加载密钥,'6'。 – Vahid

+0

'_pickle.UnpicklingError:无效加载密钥,'3'。 '看起来在某些情况下'.load_word2vec_format()'可以提供帮助。 – mrgloom

相关问题