简体   繁体   English

无法运行Gensim LDA

[英]Trouble running Gensim LDA

I'm trying to run the distributed LDA example as described here: 我正在尝试运行分布式LDA示例,如下所述:

https://radimrehurek.com/gensim/dist_lda.html https://radimrehurek.com/gensim/dist_lda.html

I created the set of documents by following the tutorial here: 我按照以下教程创建了一组文档:

https://radimrehurek.com/gensim/dist_lsi.html https://radimrehurek.com/gensim/dist_lsi.html

by "inflat[ing] the corpus to 1M documents, by repeating its documents over&over" as it suggests 通过“将文件扩展到1M文档,通过一遍又一遍地重复其文档”,如其所暗示的那样

I'm using python 3.3 and numpy 1.9.2 I keep getting the following error: 我正在使用python 3.3和numpy 1.9.2我一直收到以下错误:

Exception in thread oneway-call:
Traceback (most recent call last):
  File "/usr/lib64/python3.3/threading.py", line 901, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.3/site-packages/Pyro4/core.py", line 1484, in run
    super(_OnewayCallThread, self).run()
  File "/usr/lib64/python3.3/threading.py", line 858, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.3/site-packages/gensim/models/lda_worker.py", line 71, in requestjob
    self.processjob(job)
  File "/usr/lib64/python3.3/site-packages/gensim/utils.py", line 98, in _synchronizer
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.3/site-packages/gensim/models/lda_worker.py", line 80, in processjob
    self.model.do_estep(job)
  File "/usr/lib64/python3.3/site-packages/gensim/models/ldamodel.py", line 480, in do_estep
    gamma, sstats = self.inference(chunk, collect_sstats=True)
  File "/usr/lib64/python3.3/site-packages/gensim/models/ldamodel.py", line 423, in inference
    if doc and not isinstance(doc[0][0], six.integer_types):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I ran the distributed lsi example and it ran fine, but for some reason I couldn't seem to get the lda to work. 我运行分布式lsi示例,它运行正常,但由于某种原因,我似乎无法使lda工作。

I tried changing line 423 in /usr/lib64/python3.3/site-packages/gensim/models/ldamodel.py to: 我尝试将/usr/lib64/python3.3/site-packages/gensim/models/ldamodel.py中的第423行更改为:

if doc is not None and not isinstance(doc[0][0], six.integer_types):

The error went away, but I got a warning that 错误消失了,但我收到了警告

FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.

Could someone explain what I've done wrong? 有人能解释我做错了什么吗? Is my change to this file correct? 我对此文件的更改是否正确? Or should I be running LDA differently? 或者我应该以不同的方式运行LDA?

This a bug in gensim which is raised here . 这是gensim中的一个错误,在这里提出。

EDIT - This issue is now resolved in this pull request . 编辑 - 此问题现已在此拉取请求中得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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