46

I have a program in python that uses tqdm to output progress bar which shows like below:

  0%|          |   1/782 [00:02<31:00,  2.38s/it, loss=0.763 ]
 17%|█▋        | 134/782 [00:19<01:21,  7.98it/s, loss=0.375 ]
100%|██████████| 782/782 [03:50<00:00,  2.73it/s, loss=0.0193]
100%|█████████▉| 779/782 [03:47<00:00,  4.33it/s, loss=0.0175]
100%|█████████▉| 780/782 [03:48<00:00,  4.08it/s, loss=0.0172]
100%|█████████▉| 781/782 [03:48<00:00,  3.83it/s, loss=0.0195]

Lets take 2nd row:

 17%|█▋        | 134/782 [00:19<01:21,  7.98it/s, loss=0.375 ]

The fields in order are:

  • 17%: Percentage complete.
  • |█▋ | : Progress bar
  • 134/782: Number of items iterated over total number of items.
  • [00:19<01:21, 7.98it/s, loss=0.375 ]: Lets break this down below separately.
    • 00:19<01:21 : <<HERE>> Cant' figure this out.
    • 7.98it/s: iterations per second
    • loss=0.375: As the label says, it is the loss.

I understand that it is showing progress and stats like, iterations per second, loss obtained etc. However I am not able to precisely say what this time format ( 00:19<01:21 for example ) represents in every row? What does the < sign indicate?

2
  • 30
    This is "runtime" < "estimated time left". The time flows from right to left, i.e. the time that elapsed is substracted from the right (estimated time left) statement and added to the left (runtime). In the ideal case with a constant number of iterations per second, you start like 00:00<05:00 and end up with 05:00<00:00.
    – Shintlor
    Commented Oct 12, 2018 at 10:30
  • why is that the first bar is not completed
    – Sam
    Commented Mar 2, 2023 at 9:42

2 Answers 2

34

In the source code [1] there is a comment about it in format_meter method, it refers to {elapsed}<{remaining}

[1] https://github.com/tqdm/tqdm/blob/master/tqdm/std.py#L397

1
10

The value 00:19 in 00:19<01:21, 7.98it/s is the elapsed time, while the value 1:21 is the remaining time, acording to the iterations per second value. Hence, it is not a static value.

2
  • What does it mean by iteration then?
    – avocado
    Commented May 10, 2022 at 20:00
  • 1
    By iteration it means completing one loop. Iteration/s is how many times the code can complete one loop per second Commented Aug 8, 2022 at 19:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.