jhlau / doc2vec

Python scripts for training/testing paragraph vectors
Apache License 2.0
640 stars 191 forks source link

AttributeError: 'Doc2Vec' object has no attribute 'wv' #9

Closed susierao closed 7 years ago

susierao commented 7 years ago

Dear doc2vec developers, I have been trying to use your code to build my own dbow model based on pre-trained word embeddings of google news corpus. The pre-trained word embeddings were successfully loaded in.

The following errors I encountered could not be solved:

2017-05-01 21:53:33,486 : INFO : expecting 80380 sentences, matching count from corpus used for vocabulary survey Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.target(*self.args, **self.__kwargs) File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 740, in worker_loop tally, raw_tally = self._do_train_job(sentences, alpha, (work, neu1)) File "/usr/local/lib/python2.7/dist-packages/gensim/models/doc2vec.py", line 669, in _do_train_job doctag_vectors=doctag_vectors, doctag_locks=doctag_locks) File "gensim/models/doc2vec_inner.pyx", line 271, in gensim.models.doc2vec_inner.train_document_dbow (./gensim/models/doc2vec_inner.c:3511) word_vectors = model.syn0 AttributeError: 'Doc2Vec' object has no attribute 'wv'

Can you provide me with some hints where could possible go wrong?

Thanks a lot in advance.

Best regards, Susie

jhlau commented 7 years ago

Looks like the latest gensim has changed the interface a little.

You can use my forked version of gensim and it should work: https://github.com/jhlau/gensim

aymansalama commented 6 years ago

i used the forked gensim and still same error.

jhlau commented 6 years ago

Sounds like you probably didn't install the forked gensim properly (and that it's still loading from a newer version of gensim)...

aymansalama commented 6 years ago

thank you for the quick reply. any recommendation