A batch dimension is the first axis of a tensor containing a fixed-size group of samples. Deep learning models process these groups instead of an entire dataset at once. section 2.2.7
MNIST batches
MNIST stores digit images with samples on the first axis. Selecting rows 1–128 creates one batch; selecting rows 129–256 creates the next. Each batch has a batch size of 128, while the remaining axes describe each image. section 2.2.7 section 2.2.5
Read the batch dimension together with the axes describing each sample:
- Vector data uses shape (samples, features), such as (100000, 3) for people described by age, gender, and income. section 2.2.8
- Sequence data uses shape (samples, timesteps, features), keeping the batch dimension before the time axis. section 2.2.8
- Image data uses shape (samples, height, width, channels), with one image represented after the batch axis. section 2.2.8
x <- as.array(c(12, 3, 6, 14, 7)) str(x) num [1:5(1d)] 12 3 6 14 7 dim(x) [1] 5
Inspecting tensor shapes makes the number of axes explicit; batch tensors add a leading samples axis to the per-sample structure. section 2.2.2 section 2.2.7
