Look at the implementation of the Dataset, you should also some sort of “collate function” to turn multiple samples into a batch like collate_fn(train_set[x] for x in ind), e.g. loader.default_collate()