Keras CNN,详细的训练进度条显示 [英] Keras CNN, verbose training progress bar display

查看:1229
本文介绍了Keras CNN,详细的训练进度条显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Keras中运行CNN.当它开始运行model.fit时,它将为每个批次打印进度条,像这样

Running CNN in Keras. When it starts to run model.fit, it prints progress bar for each batch, like this

是否可以显示每个时期的进度条?像这样

Is it possible to display the progress bar for each epoch? Like this

这是我使用model.fit(x_train, y_train, nb_epoch = 1, batch_size = 32, verbose=1)的方式 我尝试将verbose设置为0和2,但是没有进度条.

Here is how I am using model.fit(x_train, y_train, nb_epoch = 1, batch_size = 32, verbose=1) I have tried to set verbose to 0 and 2, but there is no progress bar.

如果您有任何想法,请告诉我.非常感谢

Please let me know if you have any thoughts. Many thanks

推荐答案

我在https://stackoverflow.com/a/57475559/9531617 .引用我自己:

只需安装ipykernel并将其导入您的代码即可解决该问题,而无需修改源代码:

The problem can be fixed without modifying the sources by simply installing ipykernel and importing it in your code:

pip install ipykernel 然后 import ipykernel

实际上,在Keras的generic_utils.py文件中,(在我的情况下)调查行是:

In fact, in the Keras generic_utils.py file, the probematic line was (in my case):

            if self._dynamic_display:
                sys.stdout.write('\b' * prev_total_width)
                sys.stdout.write('\r')
            else:
                sys.stdout.write('\n')

self._dynamic_displayFalse的位置,而必须为True才能正常工作.但是值self._dynamic_display已启动,例如:

Where the self._dynamic_display was False, whereas it needed to be True to work properly. But the value self._dynamic_display was initiated such as:

        self._dynamic_display = ((hasattr(sys.stdout, 'isatty') and
                                  sys.stdout.isatty()) or
                                 'ipykernel' in sys.modules)

因此,加载ipykernel会将其添加到sys.modules中,并为我解决了该问题.

So, loading ipykerneladded it to sys.modules and fixed the problem for me.

这篇关于Keras CNN,详细的训练进度条显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆