Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display training progress bar in tensorflow?

I'm trying to output to the terminal the same type of training progress bar that is done with Keras training. I'm new to tensorflow and have not yet tried Keras, but I'm interested in knowing if it can be done without Keras.

like image 957
Bill Avatar asked Jul 26 '19 06:07

Bill


2 Answers

import tensorflow as tf
train_data = (...) 
progbar = tf.keras.utils.Progbar(len(train_data))

for i, d in enumerate(train_data):
    (train model here...)
    progbar.update(i) # This will update the progress bar graph.


3714/3715 [============================>.] - ETA: 20s
  • In Tensorflow (v1.1~ 2.1), it is recommended to use tf.keras.utils.Progbar() instead of importing tqdm.
  • FYI, use tf.print(), instead of python native print function.
like image 78
EyesBear Avatar answered Oct 20 '22 15:10

EyesBear


Maybe I don't fully understand your training progress bar's meaning:
But I think you can try a python package:tqdm, put it into your training loop:

from tqdm import tqdm
for i in tqdm(range(10000)):
    ...

then you will get something like that:

100%|██████████| 10000/10000 [00:00<00:00, 1383300.02it/s]

There is tqdm's doc. https://tqdm.github.io/.

like image 5
Hu Xixi Avatar answered Oct 20 '22 14:10

Hu Xixi