The channels-first convention places an image’s color-channel axis immediately after the batch axis: (samples, channels, height, width). It contrasts with channels-last, which places channels at the end. section 2.2.8
For image batches, the convention changes the shape without changing the image content:
- A batch of 128 grayscale 256 × 256 images uses (128, 1, 256, 256). section 2.2.8
- A batch of 128 color 256 × 256 images uses (128, 3, 256, 256). section 2.2.8
- Individual images are represented as (channels, height, width), rather than (height, width, channels). section 8.1
Configuring Keras
Keras supports both formats. Set config_set_image_data_format("channels_first") to change its default, or pass data_format to an individual convolution or pooling layer. Unless a specific need requires channels-first, the default can remain unchanged. section 8.1
