还有什么解决方案可以将现有的Googlenews W2v加载到gensim中,并用其他语料库对其进行微调吗?

为了微调word2vec中的gensim嵌入,以下代码段与以前的版本一起使用:

model = Word2Vec.load_word2vec_format('GoogleNews-vectors- 
negative300.bin.gz',binary=True)

但是,我收到了错误消息Word2Vec.load_word2vec被取消: DeprecationWarning: Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead. 当我使用

model = gensim.models.KeyedVectors.load_word2vec_format('GoogleNews- 
vectors-negative300.bin.gz',binary=True)

,然后尝试使用训练方法对模型进行微调,如下所示:

model.train((corpus,total_examples=len(corpus2),epochs=10) )

我收到以下错误:

“ AttributeError:'Word2VecKeyedVectors'对象没有属性'train'”

还有什么解决方案可以将现有的Googlenews W2V加载到gensim并用其他语料库进行微调吗?

对于用户:10473854的响应:由于模块已被取消使用,因此忽略警告不起作用。另外,使用下载的嵌入路径运行Word2Vec会使Word2Vec失败。检查一下:

model = Word2Vec('GoogleNews-vectorsnegative300.bin.gz')
model.wv.vocab

{'/': <gensim.models.keyedvectors.Vocab at 0x7ff6101c3940>,'a': <gensim.models.keyedvectors.Vocab at 0x7ff6101c39e8>,'e': <gensim.models.keyedvectors.Vocab at 0x7ff6101c3278>}
zhang_box 回答:还有什么解决方案可以将现有的Googlenews W2v加载到gensim中,并用其他语料库对其进行微调吗?

我在此answer

中为GloVe向量写了类似的东西

基本上从GloVe向量开始,并使用gensim对其他语料库进行微调。

以类似的方式,它也可以用于Google新闻载体。

要点在于,您需要为语料库中已经存在于Google新语料库中的单词的旧矢量设置隐藏层。

本文链接:https://www.f2er.com/2540025.html

大家都在问