Brandon Garcia
Brandon Garcia

Reputation: 71

Gensim doc2vec infer_vector method missing

Have a hell of a blocker trying to use Gensim's doc2vec.

I import gensim.models.doc2vec.Doc2Vec and successfully train it on a set of tweets. I am able to pull my document vectors fine, using model['DOC_[0123..]''.

My issue now is that I'm trying to get a vector representation for a new, unseen document so that I can feed that vector back into a classifier. As far as I know, the only method that exists to do this with doc2vec is infer_vector().

HOWEVER, when I try to call this method, I get the following:

AttributeError: 'Doc2Vec' object has no attribute 'infer_vector'

I'm able to use all the other methods described in the doc2vec documentation: https://radimrehurek.com/gensim/models/doc2vec.html

I've tried using different versions of gensim including 0.10.3 (the version released with doc2vec || http://rare-technologies.com/doc2vec-tutorial/) and the 0.13.1 (latest version).

PLEASE HELP.

Upvotes: 2

Views: 1906

Answers (1)

gojomo
gojomo

Reputation: 54153

The latest versions (specifically 0.12.1+) have this method; if you're getting that error, you may be using an older version, from a path/environment/python-interpreter that isn't pulling its libraries from where you expect.

Uninstall gensim and run your python, confirming gensim is actually gone from the python-environment you're using. Then re-install the latest gensim, and the expected version/methods should be available.

Upvotes: 1

Related Questions