Learner
Learner

Reputation: 85

'gensim.models.doc2vec' has no attribute 'LabeledSentence'

I am using gensim in python 3 as shown within image below

 Image

In line no 11 I am getting the following error:

Image

Upvotes: 0

Views: 3997

Answers (2)

Dushyant Verma
Dushyant Verma

Reputation: 11

Use in this way:

from gensim.models.deprecated.doc2vec import LabeledSentence

or better use:

from gensim.models.doc2vec import TaggedDocument

Upvotes: 0

shadowsheep
shadowsheep

Reputation: 15002

It's a deprecated import:

https://github.com/RaRe-Technologies/gensim/issues/1886

if you want to use LabeledSentenced you must import it from the deprecated section:

from gensim.models.deprecated.doc2vec import LabeledSentence

So you have to do this:

LabeledSentence = gensim.models.deprecated.doc2vec.LabeledSentence

Upvotes: 2

Related Questions