Keras CNN,详细的训练进度条显示 [英] Keras CNN, verbose training progress bar display
问题描述
在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_display
是False
的位置,而必须为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 ipykernel
added it to sys.modules
and fixed the problem for me.
这篇关于Keras CNN,详细的训练进度条显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!