简体   繁体   中英

IndexError while using Gensim package for LDA Topic Modelling

I have a total of 54892 documents which have 360331 unique tokens. The length of the dictionary is 88.

mm = corpora.MmCorpus('PRC.mm')
dictionary = corpora.Dictionary('PRC.dict')
lda = gensim.models.ldamodel.LdaModel(corpus=mm, id2word=dictionary, num_topics=50, update_every=0, chunksize=19188, passes=650)

Whenever I run this script I get this error:

Traceback (most recent call last):
File "C:\Users\modelDeTopics.py", line 19, in <module>
lda = gensim.models.ldamodel.LdaModel(corpus=mm, id2word=dictionary, num_topics=50, update_every=0, chunksize=19188, passes=650)
File "C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg\gensim\models\ldamodel.py", line 265, in __init__
self.update(corpus)
File "C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg\gensim\models\ldamodel.py", line 445, in update
self.do_estep(chunk, other)
File "C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg\gensim\models\ldamodel.py", line 365, in do_estep
gamma, sstats = self.inference(chunk, collect_sstats=True)
File "C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg\gensim\models\ldamodel.py", line 318, in inference
expElogbetad = self.expElogbeta[:, ids]
IndexError: index 8 is out of bounds for axis 1 with size 8

I check on the internet, it is mentioned that i might be related to the RAM the computer has. I am using Windows 7 32-bit with 4 GB RAM. What change should I make in the script?

Please help!

Looks like a problem with your dictionary . 88 unique words doesn't sound reasonable.

Posting a full log would reveal more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM