How to shuffle data in Dataloader

Note that by default (at least in Libtorch 1.1) the dataset will be shuffled.
You can change that behaviour by specifying a sampler (from torch::data::samplers::[your sampler of choice].

To construct a dataloader with a sequential sampler:

auto data_loader = torch::data::make_data_loader<torch::data::samplers::SequentialSampler>(std::move(dataset), batch_size);