10/2050
Convolutional Neural Networks (CNN) — Image Processing · Page 2 of 2

Pooling, Flattening & CNN Architecture

32 min Intermediate

Pooling (Dimensionality Reduction)

After convolution, feature maps are still large. Pooling reduces size while keeping important info.

Max Pooling

Take the maximum value in each window:

Input (4×4):
[1 2 | 3 4]
[5 6 | 7 8]
-----+-----
[9 10| 11 12]
[13 14| 15 16]

Max Pool (2×2 window):
[6  8]     ← Max of [1,2,5,6], [3,4,7,8], etc.
[14 16]

Why? Keeps strongest activation (most relevant feature).

Average Pooling

Take average instead of max:

[1 2 | 3 4]   Average Pool (2×2):
[5 6 | 7 8]   [3.5  6.5]
-----+-----
[9 10| 11 12] [11.5 14.5]
[13 14| 15 16]

Full CNN Architecture

Input Image (224×224×3)
      ↓
Conv (64 filters, 3×3, ReLU) → 224×224×64
      ↓
MaxPool (2×2) → 112×112×64  (reduced!)
      ↓
Conv (128 filters) → 112×112×128
      ↓
MaxPool (2×2) → 56×56×128
      ↓
Conv (256 filters) → 56×56×256
      ↓
MaxPool (2×2) → 28×28×256
      ↓
Flatten → 200,704 values
      ↓
Dense (512, ReLU) → 512
      ↓
Dropout (0.5) → Drop half randomly
      ↓
Dense (1000, Softmax) → Final output

Common CNN Architectures

ArchitectureYearKey Innovation
LeNet1998First CNN (MNIST)
AlexNet2012Deep CNN + GPUs
VGG2014Showed depth matters
ResNet2015Residual connections (skip)
Inception2015Multi-scale convolutions
MobileNet2017Lightweight for phones

Use pre-trained: Don't train CNNs from scratch! Load pre-trained weights (ImageNet).

Why CNNs Work

  1. Local connectivity: Only nearby pixels connected
  2. Weight sharing: Same filter across all positions
  3. Hierarchical learning: Build up from edges to objects
  4. Translation invariance: Same object detected regardless of position
main.py
Loading...
OUTPUT
Click "Run Code" to execute…