From picture to input layer

An image is just a big array

Hover the image to read the actual numbers under the cursor. Nothing is hidden — a colour image is three stacked grids of integers from 0 to 255, and that is precisely what gets fed to a network. Then watch what happens to the parameter count when you feed it naively.

The picture

Your eye sees a scene. The machine receives the grid on the right and nothing else — no notion of edges, objects, or which pixels belong together.

What the machine receives

Three channels, stacked the same scene, separated
Red
Green
Blue
Greyscale

A 24-bit colour image is three of these. Stacked, they form an array of shape height × width × 3 — and flattened into a single row, that array is the input layer.

Choose a resolution
128

A fully connected first layer gives every hidden unit its own weight for every input value. That is the naive approach the notes describe — and the numbers below are why nobody uses it on images.

The cost of connecting everything
fully connected layer convolutional layer, same number of output maps
ResolutionInput valuesDense weightsMemory (float32)
Input neurons
Megapixels
Dense weights
Conv weights
Ratio

The arithmetic in the notes, made concrete. An 800×600 image is 480,000 pixels; at 1024×768 it is 786,432. In colour, triple it. Wire that into even a modest hidden layer of 128 units and the first layer alone needs hundreds of millions of weights — more parameters in one layer than most complete modern networks have in total, and every one of them has to be stored, transmitted, and learned from examples.

And it would not even work. A dense layer has a separate weight for every pixel position, so a feature it learns at the top-left is of no use at the bottom-right — it would have to learn "edge" again, independently, at every position in the image. Nothing in the architecture says that neighbouring pixels are related, so the network must discover the entire concept of spatial locality from data, using far more examples than anyone has.

A convolutional layer fixes both problems with the same idea. Instead of one weight per pixel, it has a small kernel — nine numbers for a 3×3 — that is slid across every position. Its parameter count is k × k × channels × filters, which depends on the size of the kernel and not at all on the size of the image: the green bar barely moves as you raise the resolution while the red one runs off the end. And because the same weights are applied everywhere, a feature learned anywhere is available everywhere. That is the whole idea behind the convolutional networks the next section describes.