方式 1

1
2
3
4
5
from tqdm import tqdm
from time import sleep

for i in tqdm(range(1000)):
sleep(0.01)

方式 2

1
2
3
text = ""
for char in tqdm(["a", "b", "c", "d"]):
text = text + char

方式 3

1
2
for i in trange(100): 
print(i)

方式 4

1
2
3
pbar = tqdm(["a", "b", "c", "d"])
for char in pbar:
pbar.set_description("Processing %s" % char)

应用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
print('epoch', epoch)
training_steps = tqdm(
range(1, FLAGS.steps_per_epoch),
initial=1, total=FLAGS.steps_per_epoch
)

# main training loop
for step in training_steps:

_, batch_loss, batch_accuracy = sess.run([
ops['optimize'], ops['log_loss'], ops['accuracy']
])
running_loss += batch_loss
running_accuracy += batch_accuracy