为了微调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>}