gensim LdaMulticore未从命令提示符运行

问题描述 投票:0回答:1

我正在使用gensim LdaMulticore来提取主题。它在Jupyter / Ipython笔记本中工作得非常好,但是当我从命令提示符运行时,循环无限期地运行。一旦执行到达LdaMulticore函数,执行就从第一个开始。请帮帮我,因为我是新手

if __name__ == '__main__': 
    model = models.LdaMulticore(corpus=corpus_train, id2word=dictionary, num_topics=20, chunksize=4000, passes=30, alpha=0.5, eta=0.05, decay=0.5, eval_every=10, workers=3, minimum_probability=0)

**RESULTS:-**
Moving to Topics Extraction Script---------------------------------
2017-08-18 18:59:36,448 : INFO : using serial LDA version on this node
2017-08-18 18:59:37,183 : INFO : running online LDA training, 20 topics, 1 passes over the supplied corpus of 400 documents, updating every 12000 documents, evaluating every ~400 documents, iterating 50x with a convergence threshold of 0.001000    
2017-08-18 18:59:37,183 : WARNING : too few updates, training might not converge; consider increasing the number of passes or iterations to improve accuracy
2017-08-18 18:59:37,183 : INFO : training LDA model using 3 processes
2017-08-18 18:59:37,214 : INFO : PROGRESS: pass 0, dispatched chunk #0 = documents up to #400/400, outstanding queue size 1
Importing required Packages

导入所需的包enter image description here

python nlp multicore gensim lda
1个回答
0
投票

LdaMulticore使用所有CPU内核来并行化并加速处理。并行化使用多处理概念;所以你必须编写你的程序,以便它支持多处理概念。

我有同样的问题,所以我用LdaModel取代了LdaMulticore并且它工作正常。

`gensim.models.LdaModel(corpus, num_topics=4, id2word=dictionary)`
© www.soinside.com 2019 - 2024. All rights reserved.