我目前正在使用9600个文档并应用Gensim LDA。对于培训部分,该过程似乎需要永远花费模型。我也尝试使用多核功能,但似乎不起作用。我跑了几乎三天,但我仍然无法获得LDA型号。我已经检查了数据和代码的一些功能。我读了这个问题Gensim ldamulticore不多处理吗?,但仍然没有得到解决方案。
corpora.MmCorpus.serialize('corpus_whole.mm', corpus)
corpus = gensim.corpora.MmCorpus('corpus_whole.mm')
dictionary = gensim.corpora.Dictionary.load('dictionary_whole.dict')
dictionary.num_pos
12796870
print(corpus)
MmCorpus(5275227 documents, 44 features, 11446976 non-zero entries)
# lda model training codes
lda = models.LdaModel(corpus, num_topics=45, id2word=dictionary,
update_every=5, chunksize=10000, passes=100)
ldanulti = models.LdaMulticore(corpus, num_topics=45, id2word=dictionary,
chunksize=10000, passes=100, workers=3)
这是我检查BLA的配置,我不确定我是否安装了适当的配置。我在这里挣扎的一件事是,我无法使用命令apt-get在Mac上安装软件包。我已经安装了Xcode,但仍然给我一个错误。
python -c 'import scipy; scipy.show_config()'
lapack_mkl_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/Users/misun/anaconda/lib']
include_dirs = ['/Users/misun/anaconda/include']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
lapack_opt_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/Users/misun/anaconda/lib']
include_dirs = ['/Users/misun/anaconda/include']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
blas_opt_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/Users/misun/anaconda/lib']
include_dirs = ['/Users/misun/anaconda/include']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
blas_mkl_info:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
library_dirs = ['/Users/misun/anaconda/lib']
include_dirs = ['/Users/misun/anaconda/include']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
我对如何在Python中使用我的字典和语料库使用Shardedcorpus的了解很糟糕,因此任何帮助都将不胜感激!我已经3天没睡了!谢谢!
我无法真正在计算机上重现您的问题,但是对我来说,您的问题似乎不是多处理,而是您的参数passes
,这对我来说似乎太高了。尝试1或2之类的东西,这应该是一个很好的参数。如果您的主题不融合,您仍然可以增加它。
lda = models.LdaModel(corpus, num_topics=45, id2word=dictionary, update_every=5, chunksize=10000, passes=1)
这最多应该在一天之内,可能只有几个小时(取决于您的机器(。