PyTorch Sampler: if specified, the next iteration samples the same subset or another subset?
If I have the code like:
dataset = Dataset(...)
sampler = RandomSampler(...)
dataloader = DataLoader(..., sampler=sampler)

Then whenever I call:
for data, label in dataloader:
   ...

The returned tuple data, label is the same subset or different subset compared to the last call?

It is different subset compared to the last call. I modify example here for your question:
data = torch.rand(10,1)
dataset = torch.utils.data.TensorDataset(torch.arange(len(data)),data)
index,_ = dataset[:]

sampler = torch.utils.data.RandomSampler(index)
loader = torch.utils.data.DataLoader(dataset, sampler=sampler, batch_size=3)

for i in range(2):
  for data, label in loader:
    print(data, label)
  print(&quot;------------&quot;)

