Can you share the code? Data Loader in PyTorch works like this. You need to define len and self.transform and you need to create class for each transformation with a call definition. The DataLoader will take the length of the dataset and create batches with just numbers(index) and will call the getitem to get the actual item(read the image) and will apply all the transformation that you specify on that item. Hope this clears things a bit.