How to initialize a new word2vec model with pre-trained model weights?

て烟熏妆下的殇ゞ 提交于 2019-12-08 08:15:04

问题


I am using Gensim Library in python for using and training word2vector model. Recently, I was looking at initializing my model weights with some pre-trained word2vec model such as (GoogleNewDataset pretrained model). I have been struggling with it couple of weeks. Now, I just searched out that in gesim there is a function that can help me to initialize the weights of my model with pre-trained model weights. That is mentioned below:

reset_from(other_model)

    Borrow shareable pre-built structures (like vocab) from the other_model. Useful if testing multiple models in parallel on the same corpus.

I don't know this function can do the same thing or not. Please help!!!


回答1:


You can now do incremental training with gensim. I would recommend loading the pretrained model and then doing an update.

from gensim.models import Word2Vec

model = Word2Vec.load('pretrained_model.emb')
model.build_vocab(new_sentences, update=True)
model.train(new_sentences)


来源:https://stackoverflow.com/questions/35985951/how-to-initialize-a-new-word2vec-model-with-pre-trained-model-weights

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!