# Model answer: CNN structure and parameter sharing

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/7/tee-c7-s11

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c7-s11/

## Question

**Question.** Explain the main layers of a convolutional neural network and why CNNs are suitable for image data. Compare them with a fully connected image network.

## Answer — step by step

A CNN processes spatially arranged data using filters that examine local regions. The same filter weights are reused at different positions. This combination of local connectivity and weight sharing builds an image-specific structure into the model and can greatly reduce the number of learned weights.

![The highlighted patch uses the same filter that will be reused at the next position.](https://deep-learning-study-room.vercel.app/assets/figures/v_weight_sharing.svg)

Diagram: The highlighted patch uses the same filter that will be reused at the next position.. Labels: Slide the same filter; reuse its weights | Slide the same filter; reuse its weights | A CNN does not learn a fresh filter for every image location. | 1 | 2 | 0 | 1 | 0 | 1 | 3 | 2 | 2 | 0 | 1 | 1 | 1 | 2 | 0 | 3 | 1 | 0 | 0 | -1 | Same four weights | 0 | -1 | -2 | 0 | 0 | 2 | 0 | 0 | -2 | Output map | Move the window to calculate the next output cell. | Local connections restrict the visible patch. Weight sharing reuses the learned | pattern.

The highlighted patch uses the same filter that will be reused at the next position. Tap the diagram to enlarge.

### Typical layer sequence

**Input → convolution → nonlinear activation → optional pooling → further feature extraction → classifier.**

| Layer | Operation | Learned parameters? |
| --- | --- | --- |
| Convolution | Multiply a local window by a filter, sum and add its bias | Filter weights and usually one bias per filter |
| ReLU | Replace negative values by zero | No ordinary ReLU parameters |
| Pooling | Summarize each window by maximum or average | None for ordinary max/average pooling |
| Flatten | Rearrange H × W × C values into a vector | None |
| Dense layer | Form weighted combinations of all incoming values | Weights and receiving-neuron biases |
| Softmax | Convert class scores into probabilities | No additional weights of its own |

Early filters can learn local patterns such as edges. Later layers combine features over larger receptive fields. A filter responding at several image positions uses one shared set of weights, not a new set at every location.

Flattening an image and using a dense layer does not enforce this local, shared structure. A dense layer has a separate connection weight for each input–output pair. CNNs can therefore be more parameter-efficient for visual patterns, although they still need suitable data and training. Pooling can provide some robustness to small shifts; it does not guarantee complete invariance to every translation.
