本文介绍了如何使用预先训练的模型权重初始化新的word2vec模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在python中使用Gensim库来使用和训练word2vector模型.最近,我正在考虑使用一些预先训练的word2vec模型(例如GoogleNewDataset预训练模型)来初始化我的模型权重.我一直在努力奋斗了几周.现在,我刚刚搜索出在gesim中有一个函数可以帮助我使用预先训练的模型权重来初始化模型的权重.如下所述:

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!!!

推荐答案

您现在可以使用gensim进行增量训练.我建议加载预先训练的模型,然后进行更新.

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)

这篇关于如何使用预先训练的模型权重初始化新的word2vec模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 21:50