0PricingLogin
Deep Learning Academy · Lesson

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

  1. Write a Custom Dataset Class
  2. Batching, Shuffling & num_workers
  3. collate_fn for Variable-Length Inputs
  4. Normalize and Standardize Inputs
← Back to Deep Learning Academy