# DataLoader - How to load the data in sequence

**URL:** <https://discuss.pytorch.org/t/dataloader-how-to-load-the-data-in-sequence/134064>\
**Category:** Uncategorized\
**Created:** [October 12, 2021, 7:55pm UTC](https://discuss.pytorch.org/t/dataloader-how-to-load-the-data-in-sequence/134064 "2021-10-12T19:55:36Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [October 14, 2021, 9:42pm UTC](https://discuss.pytorch.org/t/dataloader-how-to-load-the-data-in-sequence/134064/6 "2021-10-14T21:42:39Z")

</div>

Take a look at [this post](https://discuss.pytorch.org/t/how-to-use-batchsampler-with-getitem-dataset/78788/4) to check how the `BatchSampler` could work (it’ll pass a batch of indices to the ` __getitem__ ` method). To do so, you could create a custom sampling strategy in a derived sampler class and create the batch of indices [here](https://github.com/pytorch/pytorch/blob/871a31b9c444e52ba0cc6667fb317c11802ac4de/torch/utils/data/sampler.py#L227-L230).  
Let me know, if you get stuck and I can try to follow up with an example code snippet.

---

_[View the full topic](https://discuss.pytorch.org/t/dataloader-how-to-load-the-data-in-sequence/134064)._
