【问题标题】:IndexError while using Gensim package for LDA Topic Modelling使用 Gensim 包进行 LDA 主题建模时出现 IndexError
【发布时间】:2014-01-23 16:09:48
【问题描述】:

我共有 54892 个文档,其中包含 360331 个唯一标记。字典长度为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)

每当我运行此脚本时,我都会收到此错误:

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

我在网上查了一下,据说我可能与计算机的 RAM 有关。我正在使用具有 4 GB RAM 的 Windows 7 32 位。我应该对脚本进行哪些更改?

请帮忙!

【问题讨论】:

    标签: python lda topic-modeling gensim


    【解决方案1】:

    您的dictionary 似乎有问题。 88 个独特的词听起来不合理。

    发布完整的日志会揭示更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 2015-02-03
      • 2017-11-03
      相关资源
      最近更新 更多