question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Misleading warning when exiting iteration while loop

See original GitHub issue

I get the following warning in each epoch

Data iterator can not provide data anymore but required total number of iterations to run is not reached.

Looking into it, I see that the exception handler on #L416 for StopIteration, upon reaching the end of the data loader, sets should_exit = True. Then, on the next attempt to iterate, it goes through the except block again and it checks if the entire run is done by running self._is_done. This function checks if all iterations have been completed, not per epoch but for all epochs. Therefore, unless we are in the final epoch, this warning is shown for each epoch.

Is this the intended behaviour or have I done something wrong? I am seeing this behaviour while using an iterator that must be manually reset to the first element. I do this reset in a handler that runs on EPOCH_COMPLETED so after this loop has been exited, making the warning seemingly unavoidable through the API.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kilianbreathnachcommented, Jan 30, 2020

Yes, I ,manually call .reset() using a function defined to run on EPOCH_COMPLETED, as I mentioned in the original issue. I see now that if I were to use the auto_reset option, then the iterator would reset on #L436 and the loop would continue. However, the manual reset will not happen until the _run_once_on_dataset method has completed and the EPOCH_COMPLETED event is fired in the _internal_run method.

It turns out that my issue is that the iter_counter condition on #L457 is not being met. In the DaliGenericIterator, there are some options for how to fill or not fill the last batch, outlined here. The default option will lead to batches being processed at a rate that is actually quicker than the epoch_length. It seems the best option is probably to set the iterator with

fill_last_batch = False, last_batch_padded = True

but maybe you will figure out better options when you make a DALI example.

0reactions
vfdev-5commented, Jan 30, 2020

Ok I see the problem. Thanks for the feedback!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Risks & Errors in While, For & Do While Loops in C - Study.com
The misplaced semicolon can create problems with a while loop. Though this loop looks correct, because there's a semicolon after the while ...
Read more >
Ending an iteration of a loop from a subroutine - Stack Overflow
Just place the following line above your next : no warnings "exiting"; The warning is there for a reason - using next in...
Read more >
Loops: while and for - The Modern JavaScript Tutorial
Checked before every loop iteration. If false, the loop stops. body, alert(i), Runs again and again while the condition is truthy.
Read more >
Python while Loop Statements - Tutorialspoint
A while loop statement in Python programming language repeatedly executes a target statement as long as a given condition is true.
Read more >
Loops: while(), for() and do .. while() - Physics and Astronomy
The while() loop repeats as long as the condition is true (non-zero). If the condition is false the body of the loop never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found