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

word2vec.py - reset_from bug #1268

Closed
bruderjakob12 opened this issue Apr 9, 2017 · 2 comments
Closed

word2vec.py - reset_from bug #1268

bruderjakob12 opened this issue Apr 9, 2017 · 2 comments

Comments

@bruderjakob12
Copy link

Description

gensim.models.word2vec: reset_from seems to use the wrong variables for vocab and index2word

Steps/Code/Corpus to Reproduce

from gensim.models import word2vec

sentences = ['human', 'machine']
model = word2vec.Word2Vec()
model.build_vocab(sentences)
new_model = word2vec.Word2Vec()
new_model.reset_from(model)

Expected Results

new_model initialized with settings from model

Actual Results

Traceback (most recent call last):
File "test.py", line 8, in
new_model.reset_from(model)
File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 734, in reset_from
self.wv.vocab = other_model.vocab
AttributeError: 'Word2Vec' object has no attribute 'vocab'

Versions

gensim 1.0.1

Fix

gensim/models/word2vec.py

Line 734 change
self.wv.vocab = other_model.vocab
to
self.wv.vocab = other_model.wv.vocab

Line 735 change
self.wv.index2word = other_model.index2word
to
self.wv.index2word = other_model.wv.index2word

@piskvorky
Copy link
Owner

piskvorky commented Apr 9, 2017

Thank you for reporting!

@tmylk needs unit tests -- or was this solved in #1230?

@bruderjakob12
Copy link
Author

I guess it is fixed by #1230

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

2 participants