Keras Model.fit详细格式 [英] Keras Model.fit Verbose Formatting
问题描述
我正在Jupyter笔记本中运行Keras model.fit(),如果将verbose设置为1,则输出将非常混乱.
I'm running Keras model.fit() in Jupyter notebook, and the output is very messy if verbose is set to 1:
Train on 6400 samples, validate on 800 samples
Epoch 1/200
2080/6400 [========>.....................] - ETA: 39s - loss: 0.4383 - acc: 0.79
- ETA: 34s - loss: 0.3585 - acc: 0.84 - ETA: 33s - loss: 0.3712 - acc: 0.84
- ETA: 34s - loss: 0.3716 - acc: 0.84 - ETA: 33s - loss: 0.3675 - acc: 0.84
- ETA: 33s - loss: 0.3650 - acc: 0.84 - ETA: 34s - loss: 0.3759 - acc: 0.83
- ETA: 34s - loss: 0.3933 - acc: 0.82 - ETA: 34s - loss: 0.3985 - acc: 0.82
- ETA: 34s - loss: 0.4057 - acc: 0.82 - ETA: 33s - loss: 0.4071 - acc: 0.81
....
如您所见,ETA,损失,acc输出始终附加在日志中,而不是像进度条的工作原理一样替换第一行中的原始ETA/loss/acc值.
As you can see, the ETA, loss, acc outputs kept appending to the log, instead of replacing the original ETA/loss/acc values within the first line, just like how the progress bar works.
我该如何解决它,以使进度条,ETA,损失和损益只有1行; acc显示每个纪元?现在,随着训练的继续,我的细胞输出中有大量此类细胞.
How do I fix it it so that only 1 line of progress bar, ETA, loss & acc are shown per epoch? Right now, my cell output has tons of these lines as the training continues.
我正在Windows 10上运行Python 3.6.1,具有以下模块版本:
I'm running Python 3.6.1 on Windows 10, with the following module versions:
jupyter 1.0.0
jupyter-client 5.0.1
jupyter-console 5.1.0
jupyter-core 4.3.0
jupyterthemes 0.19.0
Keras 2.2.0
Keras-Applications 1.0.2
Keras-Preprocessing 1.0.1
tensorflow-gpu 1.7.0
谢谢.
推荐答案
您可以尝试Keras自适应的TQDM进度条库版本.
You can try the Keras-adapted version of the TQDM progress bar library.
- 原始 TQDM库: https://github.com/tqdm/tqdm
- TQDM的 Keras版本: https://github.com/bstriner /keras-tqdm
- The original TQDM library: https://github.com/tqdm/tqdm
- The Keras version of TQDM: https://github.com/bstriner/keras-tqdm
使用说明可以归结为:
-
安装例如每个
pip install keras-tqdm
(稳定)或pip install git+https://github.com/bstriner/keras-tqdm.git
(对于最新的dev版本)
install e.g. per
pip install keras-tqdm
(stable) orpip install git+https://github.com/bstriner/keras-tqdm.git
(for latest dev-version)
使用from keras_tqdm import TQDMNotebookCallback
使用verbose=0
或verbose=2
设置运行Keras的fit
或fit_generator
,但具有对导入的TQDMNotebookCallback
的回调,例如model.fit(X_train, Y_train, verbose=0, callbacks=[TQDMNotebookCallback()])
run Keras' fit
or fit_generator
with verbose=0
or verbose=2
settings, but with a callback to the imported TQDMNotebookCallback
, e.g. model.fit(X_train, Y_train, verbose=0, callbacks=[TQDMNotebookCallback()])
结果:
这篇关于Keras Model.fit详细格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!