# How does ConcatDataset work?

**URL:** <https://discuss.pytorch.org/t/how-does-concatdataset-work/60083>\
**Category:** Uncategorized\
**Created:** [November 5, 2019, 3:21pm UTC](https://discuss.pytorch.org/t/how-does-concatdataset-work/60083 "2019-11-05T15:21:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 6, 2019, 4:53am UTC](https://discuss.pytorch.org/t/how-does-concatdataset-work/60083/2 "2019-11-06T04:53:22Z")

</div>

Yes, the order should be preserved as shown in this simple example using `TensorDatasets`:

```python
datasets = []
for i in range(3):
    datasets.append(TensorDataset(torch.arange(i*10, (i+1)*10)))

dataset = ConcatDataset(datasets)
loader = DataLoader(
    dataset,
    shuffle=False,
    num_workers=0,
    batch_size=2
)

for data in loader:
    print(data)

```

---

_[View the full topic](https://discuss.pytorch.org/t/how-does-concatdataset-work/60083)._
