I have the below for loop:
for batch in loader:
# do something with batch
...
My loop sometimes fails, while extracting the batch from the loader. What I want to do is something similar to snippet below, but I would like to be able to continue the loop on the next value, rather than skip the rest of the values.
error_idxs = []
try:
for i,batch in enumerate(loader):
# do something with batch
...
except:
error_idxs.append(i)
The problem with the method above is that it exits out of the loop as soon as an exception happens rather than continuing with the next batch.
Is there a way to continue looping at the next batch?