Batching, Shuffling & num_workers
Configure a DataLoader for speed.
Meet the DataLoader
A dataset hands over one sample at a time, but training wants groups. The DataLoader wraps your dataset and serves it in convenient batches. 📦
from torch.utils.data import DataLoader
loader = DataLoader(ds)Batching Saves Time
Set batch_size and the loader stacks that many samples into one tensor. Bigger batches use your hardware better and smooth out noisy updates.
loader = DataLoader(ds, batch_size=32)All lessons in this course
- Write a Custom Dataset Class
- Batching, Shuffling & num_workers
- collate_fn for Variable-Length Inputs
- Normalize and Standardize Inputs