Log inStart free
LESSON 6.05 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Datasets and DataLoaders

Watch a DataLoader shuffle, batch and load samples while the training loop runs.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 6.05 · DATALOADER BAY22 SAMPLES · LOADS 134 MS IN ALL
01
Stage 1 of 6 · The dataset
A Dataset returns one sample per index. Each bar shows the time to read and decode that sample.
Explain it simply

Each card is one sample. A square is class 0 and a circle is class 1. The samples are stored class by class, like one folder of photos per class. The bar under a card is its load time, and three large files take 18 milliseconds each.

22 sample cards, 0 to 21. Samples 0 to 10 are class 0 and 11 to 21 are class 1. Load times add up to 134 ms.

samples, loadstrain steps, requestsloop waits, one-class batchesepoch time
0123456789101112131415161718192021181818the datasetdatasetloadlen(ds) = 22 · loads 4 + 3 + 3 + 4 + … = 134 ms0123456789101112131415161718192021181818the datasetdatasetloadlen(ds) = 22 · loads 4 + 3 + 3 + 4 + … = 134 ms
Toy: 22 samples, batch size 3, times in ms
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
(xi,yi)=ds[i],∑iℓi(\sy{x}{data}{x_i}, y_i) = \mathrm{ds}[i], \quad \textstyle\sum_i \sy{l}{data}{\ell_i}
N=22,∑iℓi=134 msN = 22, \quad \textstyle\sum_i \ell_i = 134\,\text{ms}

Index i returns one sample and takes its load time.

Common mix-ups

MYTHMore worker processes always make the epoch faster.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With shuffle off, how many of the 7 full batches mix both classes?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.