Solved by ptrblck in post #2 
              
              
                You could create an iterator via loader_iter = iter(loader) and get the next batch via batch = next(iter). If you’ve set shuffle=True in the DataLoader, these batches will contain random samples.