0

When I load doc2vec model from pkl file, I get this error.

    ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-45-5ed9dc71f3a6> in <module>()
----> 1 temp_docky.infer_vector(['paypal'])

C:\Users\Laxmikant\Anaconda\lib\site-packages\gensim\models\doc2vec.pyc in infer_vector(self, doc_words, alpha, min_alpha, steps)
    750                 train_document_dm(self, doc_words, doctag_indexes, alpha, work, neu1,
    751                                   learn_words=False, learn_hidden=False,
--> 752                                   doctag_vectors=doctag_vectors, doctag_locks=doctag_locks)
    753             alpha = ((alpha - min_alpha) / (steps - i)) + min_alpha
    754 

C:\Users\Laxmikant\Anaconda\lib\site-packages\gensim\models\doc2vec_inner.pyx in gensim.models.doc2vec_inner.train_document_dm (./gensim/models/doc2vec_inner.c:5165)()
    406     # default vectors, locks from syn0/doctag_syn0
    407     if word_vectors is None:
--> 408        word_vectors = model.wv.syn0
    409     _word_vectors = <REAL_t *>(np.PyArray_DATA(word_vectors))
    410     if doctag_vectors is None:

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

Can you please help with the error?

Amnesiac
  • 661
  • 1
  • 10
  • 30

1 Answers1

0

What version of gensim was the model saved from, and what version are you loading it into? (The way word-vectors are stored inside the model has changed in recent versions.)

Generally gensim has tried to ensure old models load correctly, but some releases have had oversights in such backwards-compatiblity... so it is also worth trying the very-latest gensim, to see if it loads your older model without this error. (And if it gives the same error, report it as a bug on the project discussion list or Github project bug tracker.)

gojomo
  • 52,260
  • 14
  • 86
  • 115