When shuffle is True
for DataLoader
class what is the default Sampler then?
From the docs:
shuffle (bool, optional): set to ``True`` to have the data reshuffled
at every epoch (default: ``False``).
If I don’t set the Sampler one must be used by default. Can you give any clue?
ptrblck
2
If no sampler was specified and shuffle=True
, the RandomSampler
will be used as shown in this line of code.
Thanks, from there I also saw one interesting line
if batch_sampler is None:
So if we set the batch_sampler=bs
where bs
is instance of the class BatchSampler
we are OK?
So I guess if we do have batch_size
greater than 1 for our DataLoader
it is more common to use the BatchSampler
?
ptrblck
4
Yes, if no batch_sampler
was provided, the sampler
(either default or passed) will be wrapped in a BatchSampler
instance.
@ptrblck if i dont give sampler and shuffle is also false.
How are items retrieved by dataloader.
BaruchG
(Baruch)
6
Using the SequentialSampler as shown in this line, a couple lines below the above. You can find more information about it at https://pytorch.org/docs/stable/data.html#torch.utils.data.SequentialSampler
Thanks I use that but dont know why i get an error