liveBook · Manning

Channels-last convention

As explained in Deep Learning with R, Third Edition

The channels-last convention places an image tensor's color-channel axis after its spatial axes.

The channels-last convention places an image tensor’s color-channel axis after its spatial axes. A batch of images therefore uses the order (samples, height, width, color_depth). section 2.2.8

Batch of grayscale and color images

A batch of 128 grayscale images measuring 256 × 256 has shape (128, 256, 256, 1). The equivalent color-image batch has shape (128, 256, 256, 3). Channels-first would instead place the color axis immediately after the batch axis: (128, 1, 256, 256) or (128, 3, 256, 256). section 2.2.8

Figure 2.3 A rank-4 image data tensor
figure

Use the rank-4 image-tensor figure to visualize how samples, height, width, and color depth form the batch shape. section 2.2.8

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines tensor ordering with grayscale, color, and video shapes, while stopping short of implementation details.
Examples
Uses 128-image grayscale and color batches plus rank-5 batches of sampled video clips.
What it assumes
Assumes familiarity with tensor shapes and dimensions while illustrating rank-3, rank-4, and rank-5 data from concrete examples.
What you can do after
Evaluate image tensor shapes and identify whether color depth follows or precedes spatial dimensions.
How it connects
Connects image tensors to batch dimensions, color channels, channels-first convention, video tensors, JAX, TensorFlow, PyTorch, and Keras.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.