Iterate DataLoader without using enumerate

pytorch version : 0.4.1

Using older version of pytorch, because 1.0.0 cannot convert to caffe model by pytorchToCaffe, tried to save pytorch model as onnx format, but the onnx model export by pytorch cannot load by mxnet or opencv, don’t know which one got bug(mxnet, pytorch or opencv4.0).

I would like to iterate DataLoader without using enumerate, because part of the images my throw exception. So I would like to put a try…exception block inside the for loop, like this

pseudo codes

dataloader =, batch_size=args['batch_size'], shuffle=True, num_workers=args['number_of_worker'])

for i in range(len(dataloader)):
    dataloader[i] //do not support
    dataloader(i)//do not support
    next(dataloader)//do not support

Any idea? Thanks

Found solution, need to convert dataloader to iterator first

dataloaderIter = iter(dataloader)