简体   繁体   English

Gensim LDA 日志不显示

[英]Gensim LDA logging not displaying

I am currently training an LDA model in gensim and would like to know if the model is converging or not.我目前正在 gensim 中训练一个 LDA 模型,并想知道该模型是否收敛。 Unfortunately I get no logging output.不幸的是,我没有得到日志输出。 The relevant code looks like this:相关代码如下所示:

from gensim.models.ldamodel import LdaModel
import logging
logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO)
logging.root.level = logging.INFO
model = LdaModel(corpus=corpus, id2word=id2word, num_topics=6, random_state=0, chunksize=100, alpha='auto', per_word_topics=True, iterations = 100, passes = 2, eval_every=1)

When I use this: logging.info("hello world") this works fine however in my jupyter notebook.当我使用这个时: logging.info("hello world")这在我的 jupyter 笔记本中工作正常。 If anybody had an idea how I could get the logging output from gensim, I'd be really gratefull.如果有人知道如何从 gensim 获取日志输出,我将非常感激。

I had the same problem with DEBUG logging (INFO worked though).我在调试日志记录方面遇到了同样的问题(虽然信息有效)。 I solved it by manually removing handler from the logging object:我通过从日志对象中手动删除处理程序来解决它:

for handler in logging.root.handlers[:]:
   logging.root.removeHandler(handler)

Maybe it will work also for fixing INFO logging.也许它也适用于修复 INFO 日志记录。

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

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