The main steps the pytorch DataLoader
follows when loading a batch of data, from a high level, are as follows:
- If
BatchSampler
is provided, it uses it to get batch of indices; otherwise, it usesSampler
,batch_size
, anddrop_last
to get get the batch of indices - Get the items from the dataset using the above indices
- If
collate_fn
is provided, it uses it on the items returned from the dataset; otherwise, it uses thedefault_collate
function to get the final output on each iteration