A digital image is a 2D grid of pixels. Each pixel holds a vector of channel values. Keeping the grid intact makes one image a rank-3 tensor with axes for height, width, and channels; a batch adds a samples axis, giving shape (samples, height, width, channels). section 2.2.8
When the grid is flattened
For a Dense-layer digit classifier, each 28 × 28 image is reshaped into 784 values. The resulting training and test arrays have shapes (60000, 784) and (10000, 784). Converting them to float32 and dividing by 255 prepares the values used by the model. These are still images as input examples, but their tensor shape no longer preserves separate height and width axes. section 2.5
(train_images, train_labels), (test_images, test_labels) = mnist.load_data() train_images = train_images.reshape((60000, 28 * 28)) train_images = train_images.astype("float32") / 255 test_images = test_images.reshape((10000, 28 * 28)) test_images = test_images.astype("float32") / 255
The reshape and scaling code shows how image examples become two-dimensional sample-by-feature arrays. section 2.5
An image’s channel values are also a representation choice. RGB and HSV encode the same color image differently: selecting red pixels is simpler in RGB, while reducing saturation is simpler in HSV. For a pretrained image model, apply its model-specific preprocessing so input values match the range used during pretraining. section 1.4 section 10.2
Images need not be fixed inputs. To inspect a convolutional filter, start with a blank image and adjust its values to increase that filter’s activation. The resulting image displays a pattern the filter responds to. section 10.2















