Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sihwapark opened this issue Jan 7, 2019 · 5 comments
Open

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

sihwapark opened this issue Jan 7, 2019 · 5 comments

Comments

@sihwapark
Copy link

sihwapark commented Jan 7, 2019

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.

@simon-roca
Copy link

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.

@sihwapark
Copy link
Author

@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.

@Noxius888
Copy link

@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?

@thanhkhocnhe
Copy link

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

@nangsanhom
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants