Part 1 Why Not Dense Layers for Images?
Loss of spatial structure: Flattening 2D images into 1D vectors destroys pixel adjacency, discarding shapes, lines, and textures.
Parameter explosion: Connecting every pixel to hidden units produces millions of weights, causing severe memory overhead and overfitting.
No spatial weight sharing: Shifting an object forces dense layers to relearn it from scratch, as weights are tied to fixed pixel coordinates.
Part 2 The Convolution Operation & ReLU
Filter (Kernel): A small matrix of weights (e.g. 3 × 3 ) that slides over pixels to detect visual features.
Stride (S): The step size in pixels the filter shifts horizontally and vertically across the image.
Padding (P): Extra border pixels (usually zeros) added around image edges to prevent spatial shrinkage.
Feature Map: The 2D output grid storing the dot-product response at each filter position.
ReLU: Non-linear activation ReLU(x ) = max(0, x ) that zeros out negative values.
Image Scene:
1. Vertical Light Beam (Real Camera Data)
2. Slanted Shadow / Gradient
3. High-Contrast Checker Pattern
Filter (Kernel):
Vertical Edge Detector (Sobel)
Horizontal Edge Detector
Ridge / Sharpen Filter
Blur (Averaging)
Stride:
Stride = 1 (1 px step)
Stride = 2 (2 px hop)
Padding:
Padding = 0 (No pad)
Padding = 1 (Zero-padded)
Apply ReLU: max(0, x)
Click 'Play' or 'Next' to slide the 3×3 filter and calculate dot products.
Play
← Back
Next →
Show all
Reset
Step 0 / 16
Output Size =
⌊
W − K + 2P
S
⌋
+ 1
Formula Breakdown :
Input size W = 6 ,
Filter size K = 3 ,
Padding P = 0 ,
Stride S = 1 .
Plugging in the numbers: ⌊ (6 − 3 + 0) / 1 ⌋ + 1 = 3 + 1 = 4 × 4 output map .
Part 2b RGB 3-Channel Convolution
3D input volumes: Color images consist of 3 stacked 2D channels (H × W × 3 for Red, Green, and Blue).
Cross-channel summation: Dot products across all 3 color planes sum together into a single 2D feature map .
Image Preset:
1. Red Apple + Green Leaf
2. Vibrant Color Stripes
3. Traffic Light
4. Red vs. Green Contrast Border
3D Filter Preset:
Vertical Edge (Sobel across RGB)
Red-Feature Detector (R+, G-, B-)
Red-vs-Green Opponent Edge
Channel View:
Split: All 3 Channels (R, G, B)
Combined: Color Picture Only
Red Channel Plane Only
Green Channel Plane Only
Blue Channel Plane Only
Apply ReLU: max(0, x)
ONE Shared 3D Filter (3 × 3 × 3 = 27 weights): Reused across all 36 patch positions (click weights to edit)
Click 'Play' or 'Next' to slide the 3×3×3 filter volume over the RGB image.
Play
← Back
Next →
Show all
Reset
Step 1 / 36
Part 3 Feature Hierarchies
Hierarchical abstraction: Early layers detect raw visual primitives; deeper layers compose them into complex semantics.
Layer 1 (Low-level): Extracts oriented edges, color-opponent contrasts, and basic gradient bars.
Layer 2 (Mid-level): Combines edges into corners, textures, curves, and surface patterns.
Layer 3+ (High-level): Assembles mid-level contours into recognizable object parts (wheels, windows, faces).
End-to-End Visual Hierarchy: An input image (yellow car) passes through successive convolution layers, building representations from oriented edges to complex semantic parts.
Part 4 Pooling & Spatial Downsampling
Spatial downsampling: Reduces dimensions (H , W ) by selecting local window maximums for translation invariance, preserving channel depth (C ) with zero learnable parameters.
Pooling Mode:
Max Pooling (Takes the maximum)
Average Pooling (Takes the mean average)
Click 'Play' or 'Next' to step the 2×2 pooling window.
Ready. Press 'Play' or 'Next' to downsample the feature map.
Play
← Back
Next →
Show all
Reset
Step 0 / 9
Part 5 Batch Normalization
Internal covariate shift: Upstream parameter updates cause downstream feature distributions to drift continuously.
Mini-batch standardization: Normalizes each feature dimension across the batch to zero mean and unit variance.
Drift Scenario:
1. Internal Covariate Shift (Mean drifts rightwards into saturation)
2. Dying ReLU Extinction (Mean drifts negative → all neurons off)
3. Variance Explosion (Points scatter apart uncontrollably)
Without BatchNorm
With BatchNorm
Training Iteration:
Iteration 1 / 6
(8 batch activation points traveling through Layer 2)
Downstream Layer 2 Status
Optimal Inputs
Click 'Play' or drag the iteration slider to watch the activations drift across training updates.
Play Iterations
← Prev Iter
Next Iter →
Reset
Iteration 1 / 6
Standardization step: Subtracts batch mean μB , divides by standard deviation σB , then applies γ and β .
Batch Preset:
1. Wild Drift (High Variance & Shifted Mean)
2. Saturated High Values (Large Positive Shift)
3. Dying Negative Drift (Risk of Dead Neurons)
Normalized =
γ
×
x − μB
√(σB 2 + ε)
+
β
Mean (μB ): 22.3
Spread (σB ): 20.6
Current Step: 1. Raw Inputs
Ready. Click any step below or press 'Auto Play' to see how BatchNorm standardizes wild activations into stable numbers.
Auto Play
1. Raw (x)
2. Center (x − μ)
3. Standardize (÷ σ)
4. Scale & Shift (γ, β)
Reset
Step 1 / 4
Part 5b BatchNorm in CNNs (4D Tensors)
4D tensor dimensions: Convolutional activations form a 4D tensor of shape N × C × H × W .
Channel-wise pooling: Computes one mean μc and variance σc 2 across all N × H × W activations for each channel.
Consistent spatial scaling: Adheres to convolutional weight sharing by scaling all pixels in a channel identically.
Inspect Channel:
Channel 0 (High Positive Mean: μ ≈ +14.2)
Channel 1 (Dying Negative Mean: μ ≈ -8.4)
Channel 2 (Wild Variance: σ ≈ 8.5)
Mini-Batch of N = 4 Images × H × W = 3 × 3 Activations (36 total values in Channel 0 ):
Activation Distribution (Channel 0 )
Mean: +14.2 • Std: 5.8
Step 1 (Raw Activations): Showing mini-batch activations across N=4 images. Notice how the channel is off-center with wide variance.
Auto Play
1. Raw Activations
2. Pool N, H, W (μ, σ²)
3. Zero-Center (x - μ)
4. Unit Variance (÷ σ)
5. Scale & Shift (γ, β)
Reset
Step 1 / 5
Optimization conditioning: Smooths the loss surface, allowing substantially higher learning rates without divergence.
Gradient health: Mitigates vanishing and exploding gradients throughout deep network architectures.
Training Dynamics: With vs. Without BatchNorm
Drag the learning rate slider to see how BatchNorm prevents gradient explosions:
Learning Rate (η):
0.010
With BatchNorm: Stable convergence (Final Loss: 0.08)
Without BatchNorm: Slow descent (Final Loss: 0.35)
— With BatchNorm
— Without BatchNorm