How Dataloader gets images from custom dataset

I am working in a project that I have to make a dataset class. I already know that this class must has three methods: init(), getitem() and len().
The getitem() method recieve as a parameter an index of an image, for example. So, all preprocessing needed for the image is performed and in the end this preprocessed image is returned by the getitem() method.

My question is: if the dataloader is configured with batch=100. The getitem() method is called 100 times getting 100 images to generate the batch? I am asking this because the method getitem() receive just one index of an image. So, in my understanding this method returns only one image.

This is it.

Best regards,

Matheus Santos.

Yes, this is true. There also are Iterable Datasets for cases where that isn’t appropriate.

Best regards


P.S.: Using backticks (`__getitem__`) you can get the double-underbars.

Thanks for the reply!!
So, can I consider that the Dataloader calls the __getitem__() method several time as the number of the batch size? For example, batch_size = 100, the Dataloader will call the method 100 times to make the batch? Am I right?

Best regards,

Matheus Santos.

Yes. For the usual datasets, __getitem__ will be called a 100 times.
The list of 100 results are then fed to the collate_fn to make a batch.

Ahh ok!!