Issue
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
....
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.
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.
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
Thank you.
Solution
You can try the Keras-adapted version of the TQDM progress bar library.
- The original TQDM library: https://github.com/tqdm/tqdm
- The Keras version of TQDM: https://github.com/bstriner/keras-tqdm
The usage instructions can be brought down to:
install e.g. per
pip install keras-tqdm
(stable) orpip install git+https://github.com/bstriner/keras-tqdm.git
(for latest dev-version)import the callback function with
from keras_tqdm import TQDMNotebookCallback
run Keras'
fit
orfit_generator
withverbose=0
orverbose=2
settings, but with a callback to the importedTQDMNotebookCallback
, e.g.model.fit(X_train, Y_train, verbose=0, callbacks=[TQDMNotebookCallback()])
The result:
Answered By - Alaroff
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.