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 update before train error message. Fix #1162 #1205

Merged
merged 3 commits into from
Mar 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,13 @@ def update_weights(self):
for i in xrange(len(self.wv.syn0), len(self.wv.vocab)):
# construct deterministic seed from word AND seed argument
newsyn0[i-len(self.wv.syn0)] = self.seeded_vector(self.wv.index2word[i] + str(self.seed))

# Raise an error if an online update is run before initial training on a corpus
if not len(self.wv.syn0):
raise RuntimeError("You cannot do an online vocabulary-update of a model which has no prior vocabulary. " \
"First build the vocabulary of your model with a corpus " \
"before doing an online update.")

self.wv.syn0 = vstack([self.wv.syn0, newsyn0])

if self.hs:
Expand Down