本文介绍了AttributeError:类型对象"Word2Vec"没有属性"load_word2vec_format"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现word2vec模型并出现Attribute错误

I am trying to implement word2vec model and getting Attribute error

下面是代码:

wv = Word2Vec.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)
wv.init_sims(replace=True)

请让我知道这个问题?

推荐答案

您如何安装gensim,以及安装了什么版本?

How did you install gensim, and what version is installed?

gensim 1.0(当前预发行版)中的API更改将 load_word2vec_format()移至名为 KeyedVectors 的帮助程序类.

API changes in (currently pre-release) gensim 1.0 move load_word2vec_format() to a helper class called KeyedVectors.

在这一点上(2017年2月),您可能不希望使用预发行版本,除非您是经验丰富的gensim用户并密切关注发行说明 [CHANGELOG.md] [1].

At this point (February 2017) you probably don't want to be using a pre-release version unless you're an experienced gensim user and closely follow the release-notes [CHANGELOG.md][1].

如果通过此API更改有意使用gensim的更高版本,请改用:

If intentionally using a later version of gensim with this API change, you would instead use:

KeyedVectors.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)

这篇关于AttributeError:类型对象"Word2Vec"没有属性"load_word2vec_format"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:46