Hi,

firstly, why is the __getitem__ method being called so many times, since my batch is 5, I expect it to be called only 5 times

This is because the worker processes are loading batch in advance to be able to provide them to the training as quickly as possible when it asks for a new one.

Secondly, as you can see the why is it being called after I have printed the dashed lines, I have already received my first batch of data and added a break . Nothing should be printed after the dashed lines I suppose.

This most likely happens because the worker that load the data work asynchronously and load the data before the main process tells them to stop doing stuff.

Again it is being called twice.

Again because it preloads 2 batchs in advance. You can check the doc for dataloader on master and in particular the prefetch_factor argument that allows you to control how many batch are loaded in advance: https://pytorch.org/docs/master/data.html#torch.utils.data.DataLoader 7