How to obtain a batch randomly from DataLoader?

Hi guys, I’m wondering how to randomly get a mini-batch using a DataLoader like that:

train_loader = DataLoader(cifar10.Cifar10(train=True,  image_transform=cifar10.transformer), shuffle=False, batch_size=BATCH_SIZE, num_workers=BATCH_SIZE)

But it seems that just can output batches one by one:

    for (inputs, labels) in train_loader:

Is there any way enables me get i-th batch directly, or randomly get a batch? Thanks in advance.

2 Likes