Question about Dataloader for Dataset than returns more than 2 things

I have a customer pytorch dataset that reads an audio file/image files and returns image, audio, and label. I want to use DataLoader to load multiple batches but currently, I can’t. How should I address this?

You could add what you want to return in __getitem__ in your custom dataset.

class customdataset(Dataset):
    def __getitem__(self, index):
        return audio_file, image_file, label

I got that part. But how do I use this dataset with pytorch Dataloader?

Sorry for the late reply.

You could get the audio_file, image_file and label from Dataloader by this:

for i, (audio_file, image_file, label) in enumerate(dataloader):

I have not processed the audio file, but I think it will works for you by your exploration.

1 Like