Neural Networks & Deep Learning Guide 6 of 6 · tap to switch
Convolutional Neural Networks (CNNs)
See how sliding 3x3 magnifying filters, stride, padding, and pooling let neural networks recognize visual patterns anywhere in an image.
To your eyes, a photograph of a coffee mug is made of edges, curves, and handles. To a computer, it is a giant spreadsheet of pixel brightness numbers (1 = dark, 8 = bright white).
Instead of connecting every single pixel directly to every neuron, a Convolutional Neural Network (CNN) slides a tiny 3×3 magnifying glass step by step across the image. Inside that window sits a 3×3 pattern-spotting template of numbers called a filter (or kernel). At every stop, the CNN multiplies the 9 overlapping pixels by the 9 filter numbers and adds them up into a single score.
Collecting all of those scores into a new grid produces a feature map: the score grid showing exactly where that pattern (such as a vertical edge or a bright bar) lit up!
Pick an image pattern and a 3×3 filter below, then click any cell in the 4×4 Feature Map to slide the glowing purple 3×3 window across the input grid and watch the 9-pair arithmetic update live!
The magical part of Deep Learning is that you never hand-design those 3×3 numbers: Backpropagation automatically learns the exact edge, corner, eye, and wheel filters needed from labeled images!
How CNN Convolutions Work: Stride & Zero Padding
Notice what happened above: sliding a 3×3 filter across a 6×6 image shrank the output to 4×4 because the filter cannot step off the edges! Stack 10 unpadded layers and your image vanishes to nothing.
Two simple knobs control the output grid size cleanly:
- Zero Padding (
P = 1) wraps a 1-pixel frame of zeros around the border so3×3filters inspect corner and edge pixels fairly. Because adding1cell on each side (+2total) cancels the2border cells a3×3filter normally trims off, your output stays the exact same width and height (Same Padding), whether the input is6×6or16×16. - Stride (
S = 2) makes the filter hop 2 pixels per step instead of 1, neatly shrinking the grid in half!
Try the quick presets below or toggle Stride 1 versus Stride 2 to watch the dashed teal second filter step slide or jump across the grid while the output shape recalculates live!
Max Pooling: shrinking maps while ignoring tiny shifts
Once a convolutional layer spots an edge or a cat ear, you usually do not care whether that ear sat at pixel (14, 22) or (14, 23): you only care that an ear appeared in that neighborhood!
2×2 Max Pooling divides the feature map into non-overlapping 2×2 patches and keeps just the single loudest number inside each patch, shrinking the grid area by 4× (half as wide and half as tall). Click Shift Peaks 1 Pixel Right below to see why Max Pooling keeps the output 100% identical, and compare it with Average Pooling, which blends all 4 numbers together and softens sharp peaks!
Why CNNs crushed dense MLPs on vision: Parameter Sharing
Still wondering why we cannot just flatten a photo into one giant 1D list of pixels and hand it to a plain Multi-Layer Perceptron (MLP)?
Because a CNN uses parameter sharing: it slides the exact same compact 3×3 templates across every part of the image instead of wiring a brand-new weight to every pixel location. Look at the exact weight count for a 32-filter 3×3 CNN layer reading a color (Red, Green, Blue) photo:
- Each
3×3filter looks at 9 pixels across all 3 RGB color channels plus 1 baseline offset:(3×3 grid × 3 RGB colors) + 1 baseline = 28 weights. - Multiply by 32 filters:
32 filters × (3×3 grid × 3 RGB colors + 1 baseline) = 896 shared weights!
Whether the photo is a tiny 28×28 color icon or a 512×512 HD photo, doubling the width and height adds zero extra weights to that CNN layer (the computer simply slides the same 32 templates across more spots). Click through the photo resolutions below to watch a single dense MLP layer explode past 200 Million weights, while our 32-filter 3×3 CNN stays frozen at 896 shared weights!
See Multi-Channel 2D Convolution, Output Geometry & Receptive FieldsThesis / Reference
1. Multi-Channel Discrete 2D Cross-Correlation (LeCun et al., 1998): Given an input tensor (for example RGB channels) and learnable kernels with bias , output feature map at spatial index computes:
Total learnable parameters equal strictly , completely independent of spatial resolution !
2. Spatial Output Geometry & Translation Equivariance: With square input size , kernel , zero-padding , and stride :
Because the exact same filter slides across all coordinates, convolution is mathematically translation equivariant (shifting the input shifts the feature map identically), and stacking two layers achieves the exact receptive field of one kernel using 28% fewer parameters ( vs. ) plus an extra non-linearity (VGG, Simonyan & Zisserman, 2015; ResNet, He et al., 2016; ConvNeXt, Liu et al., 2022).
See a Clean Modern CNN Classifier in PyTorchOptional Code
import torch.nn as nn
# Clean Conv -> BatchNorm -> ReLU -> Pool vision block
cnn = nn.Sequential(
# Stage 1: 3 RGB channels -> 32 edge filters (Same Padding: k=3, p=1)
nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(32),
nn.ReLU(),
nn.MaxPool2d(kernel_size=2), # halves H and W
# Stage 2: 32 edge maps -> 64 higher-level part detectors
nn.Conv2d(32, 64, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(64),
nn.ReLU(),
nn.AdaptiveAvgPool2d((1, 1)), # Global Average Pooling -> (B, 64, 1, 1)
nn.Flatten(),
nn.Linear(64, 10), # 10 class logits
)Congratulations: you just completed Path 04!
Across Neural Networks & Deep Learning, you went from a single weighted Perceptron and ReLU/GELU activations all the way through Backpropagation, Gradient Descent with AdamW & Cosine Warmup, Dropout & Batch/Layer Normalization, and Convolutional Neural Networks!
Ready to see how Transformers, Self-Attention, LoRA, RAG, and AI Agents power modern LLMs? Continue straight into Path 05: Modern AI & LLMs (Tokenization & Word Embeddings) or browse the complete Visual Library.
Quick Intuition Check
Four quick real-world scenarios. No scores, just test your intuition.
You slide a 3×3 filter across a 16×16 grid using a 1-pixel zero border (padding = 1) and moving 1 cell per step (stride = 1). What is the output grid size?
You double a color photo's resolution from 224×224 pixels up to 448×448 pixels. How many MORE learnable weights does a 32-filter 3×3 CNN layer need?
What two benefits does 2×2 Max Pooling deliver inside a Convolutional Neural Network?
In a modern CNN, engineers manually hard-code fixed numbers like [-1, 0, +1] inside every convolutional layer rather than letting Backpropagation learn the filter weights.
Common Questions
What does a Convolutional Neural Network (CNN) filter actually do?
Why are CNNs so much better than plain dense MLPs for images?
What is the CNN output size formula for Stride and Padding?
What is the purpose of Max Pooling in a CNN?
Are CNNs still used now that Vision Transformers (ViTs) exist?
Related Visual Guides
Neural Networks & the Perceptron
Demystify neural networks from a single weighted switch to multi-layer perceptrons that solve XOR and approximate any curve.
Batch Normalization, Dropout & Weight Decay
Keep deep neural networks stable and prevent memorization using Dropout, Batch/Layer Normalization, Weight Decay, and Data Augmentation.
Transformer Architecture & KV Cache
Step inside the complete blueprint powering GPT, Claude, and Gemini: Pre-Norm blocks, RoPE positional encoding, Encoder vs. Decoder families, and KV Caching.
Written & illustrated by Muhammad Aashir Irshad · Updated December 2026 · Free open-access reference
Cite this guide in a paper, thesis, or course (BibTeX & APA)
@misc{irshad2026convolutionalneuralnetworks,
author = {Irshad, Muhammad Aashir},
title = {Convolutional Neural Networks (CNNs): Interactive Visual Guide},
howpublished = {SeeingML},
year = {2026},
month = {dec},
url = {https://seeingml.com/learn/convolutional-neural-networks/},
note = {Interactive visual guide}
} Irshad, M. A. (2026). Convolutional Neural Networks (CNNs): Interactive Visual Guide. SeeingML. https://seeingml.com/learn/convolutional-neural-networks/