2

I am reading the official documentation of Dataloaders:

https://pytorch.org/tutorials/beginner/basics/data_tutorial.html

And there is this sentence "DataLoader wraps an iterable around the Dataset.."

I know that dataloaders are used to iterate over the dataset but what I don't get is that what does wrapping an iterable over the dataset means? I want an insight of the theoretical point of view.

Nephophile
  • 59
  • 1
  • 10

1 Answers1

1

The sentence means that a DataLoader can be used to iterate the contents of a Dataset. For example, if you've got a Dataset of 1000 images, you can iterate certain attributes in the order that they've been stored in the Dataset and nothing else by itself. In the other hand, a DataLoader that wraps that Dataset allows you to iterate the data in batches, shuffle the data, apply functions, sample data, etc. Just checkout the Pytorch docs on torch.utils.data.DataLoader and you'll see all of the options included.

aaossa
  • 3,763
  • 2
  • 21
  • 34
  • So, it means that a dataloader is used to iterate over the dataset's contents, in the order that they are stored in and can also be used for extra functions - shuffle etc (in case of wrapping). Am I right? – Nephophile Feb 26 '22 at 16:09
  • 1
    I think you almost got it. A dataloader only iterates a dataset, it does not modify it's contents. To be precise, for example, it doesn't shuffle the dataset contents, but it can iterate the contents of a dataset in a random order (not exactly the same) – aaossa Feb 26 '22 at 23:29