Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best way of tqdm for data loader

How to use tqdm for data_loader ?

is this the correct way?

for i,j in enumerate(data_loader,total = 100):
           pass
like image 715
Om Fuke Avatar asked Dec 17 '22 12:12

Om Fuke


1 Answers

You need to wrap the iterable with tqdm, as their documentation clearly says:

Instantly make your loops show a smart progress meter - just wrap any iterable with tqdm(iterable), and you’re done!

If you're enumerating over an iterable, you can do something like the following. Sleep is only for visualizing it.

from tqdm import tqdm
from time import sleep

data_loader = list(range(1000))

for i, j in enumerate(tqdm(data_loader)):
    sleep(0.01)
like image 51
Bitswazsky Avatar answered Dec 31 '22 12:12

Bitswazsky