NETL-Automatic-Topic-Labelling- icon indicating copy to clipboard operation
NETL-Automatic-Topic-Labelling- copied to clipboard

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

Open sihwapark opened this issue 7 years ago • 5 comments

Hi,

I am trying to run the pre-trained system and get the labels but I got an error below:

>>> python get_labels.py -cg -us -s
Extracting candidate labels
/usr/local/lib/python3.6/site-packages/gensim/models/doc2vec.py:566: UserWarning: The parameter `iter` is deprecated, will be removed in 4.0.0, use `epochs` instead.
  warnings.warn("The parameter `iter` is deprecated, will be removed in 4.0.0, use `epochs` instead.")
/usr/local/lib/python3.6/site-packages/gensim/models/doc2vec.py:570: UserWarning: The parameter `size` is deprecated, will be removed in 4.0.0, use `vector_size` instead.
  warnings.warn("The parameter `size` is deprecated, will be removed in 4.0.0, use `vector_size` instead.")
models loaded
Data Gathered
Traceback (most recent call last):
  File "cand_generation.py", line 72, in <module>
    model1.syn0norm = (model1.syn0 / sqrt((model1.syn0 ** 2).sum(-1))
AttributeError: 'Doc2Vec' object has no attribute 'syn0'
Executing Unsupervised model
Traceback (most recent call last):
  File "unsupervised_labels.py", line 27, in <module>
    with open(args.output_candidates,'r') as k:
FileNotFoundError: [Errno 2] No such file or directory: 'output_candidates'
Executing Supervised Model
  File "supervised_labels.py", line 236
    g.write( "Top "+args.num_sup_labels+" labels for topic "+str(cnt)+" are:" +"\n")
    ^
SyntaxError: invalid syntax

The main error is AttributeError: 'Doc2Vec' object has no attribute 'syn0' I am using Python 3.6.5 with gensim 3.6.0. I found Doc2Vec doesn't have syn0 as an attribute but it is available in model.wv.syn0. Is it okay to only change model1.syn0 to model1.wv.syn0 in code?

Or at least I would like to know which version of Python and gensim you worked with when you implemented the code.

sihwapark avatar Jan 07 '19 21:01 sihwapark

Hi,

I'm not the creator of this code but I've used it recently.

The issues working with old pre-trained models are mentioned in this thread.

I can run this code in Python 3.7.0 (Gensim 3.4.0) using model.wv when necessary and providing minor changes related to Python 2/3 incompatibilities (print calls for instance).

As far as I know, I should be obtaining the expected results.

simon-roca avatar Jan 09 '19 08:01 simon-roca

@simon-roca Thank you for the comment. Before getting your comment, I was ended up changing all gensim-related syntax for the recent version. I leave my fork for someone having the same issue.

sihwapark avatar Jan 11 '19 00:01 sihwapark

@sihwapark Hi, I have tried your version, however, when executing the code, it overflows my 16 GB of RAM and raises a memory error. Can that be possible that it needs so much RAM?

Extracting candidate labels models loaded Data Gathered Traceback (most recent call last): File "cand_generation.py", line 76, in <module> model1.docvecs.vectors_docs_norm = (model1.docvecs.vectors_docs / sqrt((model1.docvecs.vectors_docs ** 2).sum(-1))[..., newaxis]).astype(REAL)[d_indices] MemoryError

What were your experiences?

Noxius888 avatar Feb 28 '19 11:02 Noxius888

kaka, i gave 2 day to fix all syntax. filled with tired

thanhkhocnhe avatar Aug 16 '19 04:08 thanhkhocnhe

I also got the Memory error when I ran the get_labels.py -cg, although there is an enough memory. Can anyone give any suggestions?

nangsanhom avatar Sep 04 '20 16:09 nangsanhom