# CNN versus a fully connected image network

Subject: Deep Learning

Exam: TEE

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

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

**Definition.** A convolutional neural network uses local receptive fields and spatial parameter sharing, unlike a dense layer's independent connection weights. These architectural constraints exploit spatial structure and can greatly reduce parameter counts.

### Explanation and working

A fully connected layer can learn image features, but flattening pixels and connecting every pixel to every neuron ignores the useful local structure built into a CNN and can require many parameters. CNNs exploit local connections and shared filters. They learn hierarchical features and reuse a pattern detector at many locations.

![Compare where connections go and which weights are reused.](https://deep-learning-study-room.vercel.app/assets/figures/v_fc_cnn.svg)

Diagram: Compare where connections go and which weights are reused.. Labels: Fully connected and convolutional layers connect differently | Fully connected and convolutional layers connect differently | Both learn weights; the connection pattern changes. | Fully connected image layer | Every output sees every input. | Each connection has a weight. | Spatial layout is not built in. | Convolutional layer | A filter sees a local patch. | Reuse it at many positions. | Preserve a spatial feature map. | Parameter sharing makes a convolution economical when the same feature can occur | in many places.

Compare where connections go and which weights are reused. Tap the diagram to enlarge.

For a 32 × 32 × 3 input, a dense layer with 100 neurons has (3,072 + 1) × 100 = 307,300 parameters. A convolution with 100 filters of size 3 × 3 has (27 + 1) × 100 = 2,800 parameters. The outputs are different shapes, so this is a parameter-efficiency illustration, not two identical computational tasks.
