簡體   English   中英

如何使用預訓練的模型權重初始化新的 word2vec 模型?

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

我在 python 中使用 Gensim 庫來使用和訓練 word2vector 模型。 最近,我正在考慮使用一些預訓練的 word2vec 模型(例如(GoogleNewDataset 預訓練模型))來初始化我的模型權重。 我一直在努力解決它幾個星期。 現在,我剛剛發現在 gesim 中有一個函數可以幫助我用預訓練的模型權重初始化模型的權重。 這是下面提到的:

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.

我不知道這個函數能不能做同樣的事情。 請幫忙!!!

您現在可以使用 gensim 進行增量訓練。 我建議加載預訓練模型,然后進行更新。

from gensim.models import Word2Vec

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM