RuntimeError: you must first build vocabulary before training the model

1,939 views
Skip to first unread message

RaHuL VkS

unread,
Nov 23, 2015, 10:29:08 AM11/23/15
to gensim
How do i correct this error when importing Word2vec in python

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import word2vec
  File "word2vec.py", line 14, in <module>
    model = word2vec.Word2Vec(sentences, size=100, window=4, min_count=1, workers=4)
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.12.3-py2.7-linux-x86_64.egg/gensim/models/word2vec.py", line 432, in __init__
    self.train(sentences)
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.12.3-py2.7-linux-x86_64.egg/gensim/models/word2vec.py", line 690, in train
    raise RuntimeError("you must first build vocabulary before training the model")
RuntimeError: you must first build vocabulary before training the model
w2c.png
Message has been deleted

Gordon Mohr

unread,
Nov 23, 2015, 5:08:58 PM11/23/15
to gensim
[corrected repost] 

Your `sentences` corpus isn't providing any data when iterated-over. (Do you see the log line at the top of your screen-shot, "collected 0 word types from a corpus of 0 raw words and 0 sentences"? There would be real word counts there if `sentences` had provided actual text examples.)

- Gordon

RaHuL

unread,
Nov 23, 2015, 11:11:32 PM11/23/15
to gen...@googlegroups.com
ya,How to train and Vocabulary ? 

--
You received this message because you are subscribed to a topic in the Google Groups "gensim" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gensim/B_ybNLemH9Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gensim+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages