How exactly dataloader works with csv file

Pytorch data loader is supposed to take a dataset as input. The dataset is an instance of Dataset class which defines the “len” and “get” functionality.

What if instead of dataset, I give simple csv file as input to pytroch data loader. I tried and the data loader is working, but I’m not sure about the behavior of the created dataloader. I mean how will it get the len and get defined.

We had recently a similar discussion in this topic.
The DataLoader might take inputs, where __getitem__ and __len__ is defined.
E.g. this code will work:

x = [0, 1, 2]

loader = DataLoader(x)
for data in loader:

However, I would still recommend to derive your custom dataset from Dataset and pass it to the DataLoader, as this will give you more control of how __getitem__ and __len__ is implemented.

1 Like