PCCMT503 ยท MOD 2 Convolutional Neural Networks (CNN)
0 / 8 Mastered

Module 2 โ€” Convolutional Neural Networks (CNN)

Official Syllabus (PCCMT503): CNN Architectural Overview, Motivation, Layers, Filters, Parameter sharing, Regularization, Convolution and Pooling as infinitely strong prior, Variants of Convolution Operation, Efficient Convolution Computation Methods, Popular CNN Architectures (ResNet, AlexNet, VGGNet, Inception).

Merged Sources: DEEP LEARNING CONCEPTS MODULE 2.pdf (70p, supersedes duplicate MODULE 2-1.pdf), M 2.1.pptx (71 slides + 41 images), M 2.2.pdf (13p), M 2.3.pdf (9p).

Filter:

2.1 CNN Architectural Overview & Motivation (Why Not Standard MLPs?)

๐Ÿ”ฅ HIGH YIELD 3M ยท 6M Sources: MODULE 2.pdf, M 2.1.pptx
Simple Intuition (ELI5) Imagine inspecting a huge mural using an MLP: every single neuron stares at the entire wall at once โ€” millions of wires per neuron! A CNN instead hands a small magnifying glass (a 3ร—3 filter) to an inspector and slides that same glass across the image to spot edges first, then combines edges into eyes/ears, and finally recognizes "Cat"!

1. What is a CNN?

A Convolutional Neural Network (CNN / ConvNet) is a specialized deep neural network for processing data with a known grid-like topology (1D audio/time-series, 2D images, 3D video volumes) that employs mathematical convolution in place of general dense matrix multiplication in at least one layer.

2. Why CNNs Beat Traditional MLPs on Images (3 Core Motivations)

  1. Eliminates Parameter Explosion:
    • A modest 224 ร— 224 ร— 3 RGB image contains 150,528 input values. Connecting it directly to just 100 dense hidden neurons requires 15,052,800 weights in a single layer! That causes extreme memory footprint, huge computation latency, and slow convergence.
    • CNNs solve this via sparse local connectivity and parameter sharing.
  2. Automatic Hierarchical Feature Extraction: Eliminates manual hand-engineered features (Sobel/SIFT/HOG) by learning a natural hierarchy automatically:
    Raw Pixels โ†’ Low-level Edges/Blobs โ†’ Mid-level Textures/Parts โ†’ High-level Object Shapes โ†’ Class Label.
  3. Built-in Shift Invariance & Overfitting Control: Spatial weight reuse + pooling drastically shrink parameter count so models generalize from realistic datasets instead of memorizing pixel noise.
END-TO-END CNN PIPELINE: FEATURE EXTRACTION โ†’ CLASSIFICATION Input Hร—Wร—C Conv + ReLU Filters slide Feature Maps Pooling Max / Avg (โ†“) Conv + Pool Deep Shapes (Repeated) Flatten 3D โ†’ 1D vec FC Layer Dense MLP Softmax Class pแตข Feature Learning Backbone Classification Head
Figure 2.1: Complete CNN Architecture Pipeline (Feature Learning + Classification Head)

2.2 CNN Layers, Filters, Output Formula & Convolution/Pooling Numericals

๐Ÿ”ฅ GUARANTEED NUMERICALS ๐Ÿงฎ 4 WORKED PROBLEMS 3M ยท 6M ยท 9M Sources: MODULE 2.pdf, M 2.1.pptx

1. Each CNN Layer Explained

  1. Input Layer: Raw pixel tensor of shape H ร— W ร— C (e.g., 28ร—28ร—1 MNIST or 224ร—224ร—3 RGB).
  2. Convolution Layer: Slides learnable filters (kernels) across width & height to extract feature maps:
    O(i, j) = โˆ‘m โˆ‘n I(i + m, j + n) ยท K(m, n)   (CNN 2D Cross-Correlation; DSP Convolution flips K: h[nโ‚โˆ’kโ‚, nโ‚‚โˆ’kโ‚‚])
    Output Spatial Size Formula:   O = โŒŠ W โˆ’ F + 2PS โŒ‹ + 1
    where W = input size, F = filter/kernel size, P = zero-padding on each side, S = stride, and output depth = number of filters applied.
  3. Activation Layer (ReLU): Element-wise R(z) = max(0, z) introduces non-linearity, produces the rectified feature map, eliminates negative values, and speeds up convergence.
  4. Pooling Layer (Subsampling): Operates independently on each channel over a Fร—F window with stride S (typically 2ร—2, S=2):
    • Max Pooling: Retains strongest feature activation inside window; preserves sharp edges/textures (most widely used).
    • Average Pooling: Averages window pixels; gives smoother global context (also used as Global Avg Pooling before Softmax in Inception/ResNet).
  5. Flatten Layer: Reshapes Hร—Wร—C spatial feature maps into a single 1D column vector for Dense layers.
  6. Fully Connected (FC) + Output Layer: Dense MLP computes high-level combinations followed by Softmax (multi-class) or Sigmoid (binary).

2. Classic Fixed 3ร—3 Image Kernels (M 2.1.pptx Slide 9)

Identity:
000
010
000
  Edge:
10โˆ’1
000
โˆ’101
  Laplacian:
โˆ’1โˆ’1โˆ’1
โˆ’18โˆ’1
โˆ’1โˆ’1โˆ’1
  Sharpen:
0โˆ’10
โˆ’15โˆ’1
0โˆ’10
  Gaussian Blur: 116
121
242
121

3. Worked CNN Numericals (from M 2.1.pptx & MODULE 2.pdf)

Numerical 2.2A (M 2.1.pptx Slides 49โ€“50): 5ร—5 Image * 3ร—3 Filter

Given: Input I (5ร—5), Filter K (3ร—3) = [[1,0,1],[0,1,0],[1,0,1]], Padding P = 0, Stride S = 1.

I =
11100
01110
00111
00110
01100
  *   K =
101
010
101
  1. Output Size: O = (5 โˆ’ 3 + 0)/1 + 1 = 3 ร— 3.
  2. Dot products (mask keeps corners & center of every 3ร—3 patch):
    โ€ข Row 1: O(0,0) = 1+1+1+0+1 = 4;   O(0,1) = 1+0+1+1+0 = 3;   O(0,2) = 1+0+1+1+1 = 4.
    โ€ข Row 2: O(1,0) = 0+1+0+0+1 = 2;   O(1,1) = 1+1+1+0+1 = 4;   O(1,2) = 1+0+1+1+0 = 3.
    โ€ข Row 3: O(2,0) = 0+1+0+0+1 = 2;   O(2,1) = 0+1+1+0+1 = 3;   O(2,2) = 1+1+1+1+0 = 4.
  3. Resulting Convolved Feature Map: [[4, 3, 4], [2, 4, 3], [2, 3, 4]]
Numerical 2.2B (M 2.1.pptx Slide 54): 4ร—4 Max Pooling, Avg Pooling & Flatten

Given: 4ร—4 Feature Map [[1,4,2,7],[2,6,8,5],[3,4,0,7],[1,2,3,1]] with 2ร—2 filter, Stride S = 2.

  1. Output Size: (4 โˆ’ 2)/2 + 1 = 2 ร— 2.
  2. Max Pooling Quadrants:
    โ€ข Top-Left max(1,4,2,6) = 6  |  Top-Right max(2,7,8,5) = 8
    โ€ข Bottom-Left max(3,4,1,2) = 4  |  Bottom-Right max(0,7,3,1) = 7
    โ‡’ MaxPool output = [[6, 8], [4, 7]] โ†’ Flattened vector = [6, 8, 4, 7]T.
  3. Average Pooling Comparison: Averages of quadrants = [3.25, 5.5] and [2.5, 2.75].
Numerical 2.2C (M 2.1.pptx Slides 44โ€“47): 1D Valid Correlation + Source Typo Alert

Given: Signal a = [5, 3, 2, 5, 9, 7] and kernel b = [1, 2, 3] (stride 1, no padding). (Slide typo alert: Slide 44's diagram prints the 3rd element as 7, while Slides 45โ€“47 actually compute with 2!)

  1. Step 1: [5,3,2]ยท[1,2,3] = 5 + 6 + 6 = 17  |  Step 2: [3,2,5]ยท[1,2,3] = 3 + 4 + 15 = 22
  2. Step 3: [2,5,9]ยท[1,2,3] = 2 + 10 + 27 = 39  |  Step 4: [5,9,7]ยท[1,2,3] = 5 + 18 + 21 = 44
  3. Result: [17, 22, 39, 44] (length 6 โˆ’ 3 + 1 = 4).
Numerical 2.2D: Output Dimensions & Layer Parameter Count (Exam Staple)

Problem: An input volume is 32 ร— 32 ร— 3. A Conv layer applies 10 filters of size 5 ร— 5 with Stride S = 1 and Padding P = 2. Find output shape and total trainable parameters.

  1. Output H, W: O = โŒŠ(32 โˆ’ 5 + 2ร—2)/1โŒ‹ + 1 = 31 + 1 = 32 โ‡’ Output shape = 32 ร— 32 ร— 10 (Same padding!).
  2. Weights per filter (spans all 3 input channels!): 5 ร— 5 ร— 3 = 75 weights + 1 bias = 76 params/filter.
  3. Total Parameters: 10 ร— 76 = 760 trainable parameters (compare against MLP on 3072 inputs!).
LeNet-Style Digit ConvNet & CNN Training Cycle (M 2.1.pptx Slides 62โ€“69)

Classic Digit Pipeline: 32ร—32 input โ†’ Conv1 (6 filters, 5ร—5, S=1) โ†’ Pool1 (2ร—2, S=2) โ†’ Conv2 (16 filters, 5ร—5, S=1) โ†’ Pool2 (2ร—2, S=2) โ†’ FC1 (120) โ†’ FC2 (100) โ†’ Output (10 digits).
How CNNs Train: (1) Initialize filter & FC weights randomly โ†’ (2) Forward pass (Conv + ReLU + Pool + FC) โ†’ (3) Compute total error E = โˆ‘ ยฝ(t โˆ’ y)ยฒ or cross-entropy โ†’ (4) Backpropagation updates both filter kernels and FC weights via gradient descent while hyperparameters (filter count/size, stride) remain fixed.

2.3 Parameter Sharing & Regularization in CNNs

๐Ÿ”ฅ HIGH YIELD 3M ยท 6M ยท 9M Sources: MODULE 2.pdf, M 2.3.pdf

1. Parameter Sharing (Weight Sharing)

Definition: Using the exact same filter weight matrix across every spatial position (i, j) of an input image instead of learning separate weights for every individual pixel location.

  • Concrete Comparison: For a 32ร—32ร—3 image (3,072 pixels), connecting to 100 dense MLP neurons needs 307,200 weights; a shared 3ร—3 grayscale kernel needs only 9 weights (+ 1 bias) regardless of image height/width!
  • Key Benefits: (1) Dramatic reduction in parameters & memory, (2) Faster training/inference, (3) Reduced overfitting, and (4) Translation Equivariance (an eye/edge detector trained at the top-left automatically detects eyes/edges anywhere in the image).

2. Six CNN Regularization Techniques

TechniqueHow It Works & FormulaEffect / Usage in CNNs
1. DropoutRandomly sets fraction p (e.g. 0.5) of activations to 0 each training step.Prevents neuron co-adaptation; acts like training an ensemble (used in AlexNet FC6/FC7).
2. L1 (Lasso)Ltotal = L + ฮป โˆ‘ |w|Drives weak weights to exact 0 โ†’ sparse models & feature selection.
3. L2 (Ridge / Weight Decay)Ltotal = L + ฮป โˆ‘ wยฒPenalizes large weights smoothly; keeps all weights small & non-zero (standard in CNNs).
4. Data AugmentationRandom crops, horizontal flips, rotations, scaling, brightness/color jitter.Artificially multiplies dataset diversity without new labeling; builds invariance.
5. Early StoppingMonitors validation loss every epoch; stops after patience epochs without improvement.Prevents memorization by keeping weights at minimum validation error.
6. LRN (Local Response Norm)Normalizes a neuron using neighbor channels at the same pixel position (used in AlexNet).Encourages lateral inhibition between filters; later superseded by Batch Normalization.

2.4 Convolution and Pooling as an Infinitely Strong Prior

๐Ÿ”ฅ CLASSIC KTU 6M / 9M QUESTION 3M ยท 6M Source: MODULE 2.pdf
Simple Intuition (ELI5): Weak Prior vs. Infinitely Strong Prior A weak prior (like L2 regularization) is like a coach saying: "I prefer small weights, unless the data really proves otherwise." An infinitely strong prior is like putting physical blinkers on a horse or bolting rules in steel: it makes forbidden connections literally impossible (probability = zero) no matter how much data you feed!

Mathematical & Bayesian Interpretation (Goodfellow / Module 2)

  • What is a Prior? A probability distribution over model parameters reflecting prior beliefs about the task before observing training data.
  • Why "Infinitely Strong"? An L2 penalty puts a smooth Gaussian prior over weights. Convolution and Pooling instead hardwire architectural constraints that give zero probability to any weight configuration violating them โ€” gradient descent can never unlearn them.
  • What Prior Does Convolution Encode?
    1. Local Connectivity (Sparsity): Weights connecting a neuron to distant pixels outside its local patch are permanently fixed at 0.
    2. Translation Equivariance (Identical Weights): Every spatial filter weight must be identical to its shifted copies across the entire image (feature shifted in input โ†’ same shift in feature map: f(T(x)) = T(f(x))).
  • What Prior Does Pooling Encode?
    • Local Translation Invariance: The model assumes each neuron should be invariant to small shifts of local inputs (max(0, 2, 8, 7) = 8 stays 8 even if pixels shift 1 step).
  • Key Warning (When It Hurts!): Infinitely strong priors can cause underfitting if the assumptions are false โ€” e.g., where exact global coordinates matter (reading a clock face or detecting precise object placement without spatial context).
Model Exam Answer (6M): Explain Convolution and Pooling as an Infinitely Strong Prior

1. Define a prior & contrast weak priors (L2 weight decay) vs infinitely strong priors (zero probability assigned to disallowed parameters).
2. Convolution encodes local connectivity (out-of-window weights locked to 0) and translation equivariance (weights tied identical across positions).
3. Pooling encodes local translation invariance (small input shifts leave pooled output unchanged).
4. Give benefits (high statistical efficiency, less training data needed) and caveat (underfits if task violates spatial invariance or locality assumptions).

2.5 Variants of Convolution Operation (All 10 Types + 4D Tensor Equations)

๐Ÿ”ฅ HIGH YIELD 6M ยท 9M Sources: MODULE 2.pdf, M 2.2.pdf

1. Multi-Channel 4D Tensor & Strided Equations (M 2.2.pdf)

4-D Kernel Multi-Channel Conv:   Zi,j,k = โˆ‘l,m,n Vl, j+mโˆ’1, k+nโˆ’1 ยท Ki,l,m,n   (Not generally commutative unless output channels = input channels)
Downsampled / Strided Conv (stride s):   Zi,j,k = c(K, V, s)i,j,k = โˆ‘l,m,n Vl, (jโˆ’1)s+m, (kโˆ’1)s+n ยท Ki,l,m,n

2. All 10 Convolution Variants

VariantRule / MechanismOutput Size / Usage
1. Standard (2D)Slides kernel over input across channels with default stride 1.Basic feature extraction in every CNN.
2. Valid ConvolutionZero padding (P = 0); kernel stays strictly inside input bounds.Shrinks output: m โˆ’ k + 1 (e.g. 5ร—5 * 3ร—3 โ†’ 3ร—3; width-6 kernel shrinks 16 โ†’ 11 โ†’ 6 โ†’ 1).
3. Same ConvolutionPads with zeros so output size equals input size (at S = 1, P = (kโˆ’1)/2).E.g. P = 1 turns 5ร—5 โ†’ 7ร—7, giving 5ร—5 out; allows deep networks.
4. Full ConvolutionPads heavily (P = k โˆ’ 1) so every input pixel is visited k times.Expands output to m + k โˆ’ 1 (e.g. 5 + 3 โˆ’ 1 = 7ร—7 from padded 9ร—9).
5. Strided ConvolutionSteps filter by S > 1 pixels per shift.Downsamples output without separate pooling layer.
6. Dilated (Atrous) ConvInserts zeros/holes (dilation rate d) between filter weights.Expands receptive field without adding parameters (semantic segmentation / medical images).
7. Depthwise Separable(a) Depthwise spatial conv per channel + (b) Pointwise 1ร—1 cross-channel mix.Massive FLOP & param reduction (MobileNet, EfficientNet).
8. Transposed Conv (Deconv)Reverses convolution mapping to upsample small feature maps.U-Net, GAN generators, Convolutional Autoencoder decoders.
9. Locally Connected LayerSame local receptive field as CNN, but no parameter sharing (6-D tensor wi,j,k,l,m,n).Best when different image zones need different detectors (e.g., centered aligned faces).
10. Tiled ConvolutionCycles cyclically through a small bank of t distinct kernels across neighboring spatial steps.Compromise between Standard (t = 1) and Locally Connected (t = W).
CONNECTIVITY SPECTRUM: STANDARD vs. TILED (t=2) vs. LOCALLY CONNECTED Standard Conv (Full Sharing) a b a b Weights repeat: (a,b), (a,b)โ€ฆ Tiled Conv (Cycles t=2 Kernels) a b c d Alternates: (a,b), (c,d), (a,b)โ€ฆ Locally Connected (Unshared) a b e f Every link has unique weight (a..i)
Figure 2.2: Comparing Weight Sharing Across Standard, Tiled (t=2), and Locally Connected Layers (M 2.2.pdf)

2.6 Efficient Convolution Computation Methods

โญ IMPORTANT SYLLABUS TOPIC 3M ยท 6M Sources: MODULE 2.pdf + Textbook Supplement

1. Six Architectural Efficiency Methods (Directly in Uploaded PDFs)

  1. Parameter Sharing & Sparse Connectivity: Cuts dense weights from O(NยฒยทH) down to kยฒ shared weights.
  2. Stacking Small 3ร—3 Kernels instead of 5ร—5 / 7ร—7 (VGG Idea):
    • Three stacked 3ร—3 layers give the same 7ร—7 receptive field using only 3ร—(3ร—3) = 27 weights per channel instead of 7ร—7 = 49 weights (45% fewer parameters!), while inserting 3 ReLU non-linearities instead of 1.
  3. 1ร—1 Pointwise Bottleneck Convolutions (Inception & ResNet-50): Shrink channel depth first (e.g. 256 โ†’ 64) before applying expensive 3ร—3 or 5ร—5 spatial convolutions, cutting FLOPs dramatically.
  4. Depthwise Separable Convolution (MobileNet): Factorizes a standard Kร—Kร—Cinร—Cout conv (KยฒยทCinยทCout params) into depthwise (KยฒยทCin) + pointwise 1ร—1 (CinยทCout), giving ~1/Cout + 1/Kยฒ (โ‰ˆ 8โ€“9ร—) FLOP savings for K=3!
  5. Strided Convolution (S > 1): Skips intermediate spatial positions, halving width & height (4ร— fewer output computations for S=2).
Syllabus Supplement (Standard Deep Learning Textbook Methods Beyond Uploaded PDFs) The official syllabus mentions Efficient Convolution Computation Methods broadly. In case KTU asks for algorithmic/hardware acceleration (Goodfellow Ch. 9.10), add these 4 points cleanly:
  • Separable 1D Kernel Factorization: If a 2D kernel has rank 1 (K = u vแต€), replace dร—d conv (O(dยฒ)) with a dร—1 vertical conv followed by a 1ร—d horizontal conv (O(2d), e.g., Inception-v3 uses 1ร—7 + 7ร—1).
  • Fourier Transform (FFT) Convolution: Converts slow spatial convolution into fast element-wise multiplication in the frequency domain via F(I * K) = F(I) โŠ™ F(K); very fast for large kernels.
  • Winograd Minimal Filtering: Algebraic transform reducing multiplications for small 3ร—3 filters by ~2.25ร—.
  • im2col + GEMM: Unrolls input patches into matrix columns so modern GPUs compute convolution as one optimized General Matrix Multiplication (GEMM).

2.7 Popular CNN Architectures: AlexNet (2012) & VGGNet (2014)

๐Ÿ”ฅ VERY HIGH YIELD 6M ยท 9M Sources: MODULE 2.pdf, M 2.3.pdf

1. AlexNet (Krizhevsky, Sutskever, Hinton โ€” ILSVRC 2012 Winner)

  • Overview: 8 weight layers (5 Conv + 3 FC), ~60 million parameters, 16.4% / 15.3% ImageNet top-5 error.
  • Layer Pipeline (using exact 227ร—227ร—3 crop dimensions):
    1. Conv1: 96 filters 11ร—11, S=4, P=0 โ†’ 55ร—55ร—96 + ReLU + LRN + MaxPool(3ร—3, S=2) โ†’ 27ร—27ร—96.
    2. Conv2: 256 filters 5ร—5, S=1, P=2 โ†’ 27ร—27ร—256 + ReLU + LRN + MaxPool(3ร—3, S=2) โ†’ 13ร—13ร—256.
    3. Conv3 & Conv4: 384 filters 3ร—3, P=1 each โ†’ 13ร—13ร—384 + ReLU.
    4. Conv5: 256 filters 3ร—3, P=1 โ†’ 13ร—13ร—256 + ReLU + MaxPool(3ร—3, S=2) โ†’ 6ร—6ร—256 = 9,216 features.
    5. FC6 (4096, ReLU, Dropout 0.5) โ†’ FC7 (4096, ReLU, Dropout 0.5) โ†’ FC8 (1000 Softmax). (โ€œFC7 featuresโ€ became famous for transfer learning.)
  • Key Innovations: ReLU (6ร— faster than tanh), Dropout (p=0.5), Heavy Data Augmentation, Multi-GPU split across 2 GTX 580 3GB GPUs (48/48, 128/128, 192/192 channels communicating only at Conv3 & FC), LRN, Overlapping MaxPool.
Verified Source Notes on AlexNet (M 2.3.pdf vs MODULE 2.pdf p.59) M 2.3.pdf correctly explains that input crops are 227ร—227ร—3 (giving exact โŒŠ(227โˆ’11)/4โŒ‹+1 = 55), whereas Krizhevsky's original paper & MODULE 2.pdf p.59 write 224ร—224ร—3. Also ignore p.59's Indian-unit misprint (โ€œ~2.3 crore / 37.6 croreโ€) alongside โ‰ˆ 60 million total parameters (note FC6 alone has 9216ร—4096 โ‰ˆ 37.7M weights!).

2. VGGNet / VGG-16 (Visual Geometry Group, Oxford, 2014)

  • Core Philosophy: Replaced large 11ร—11 / 5ร—5 kernels with uniform small 3ร—3 filters (S=1, P=1) stacked cleanly with 2ร—2 MaxPool (S=2).
  • VGG-16 Architecture (16 weight layers = 13 Conv + 3 FC, ~138M params):
    • Input 224ร—224ร—3 โ†’ Block 1: 2ร— Conv(64) + Pool โ†’ 112ร—112ร—64
    • Block 2: 2ร— Conv(128) + Pool โ†’ 56ร—56ร—128
    • Block 3: 3ร— Conv(256) + Pool โ†’ 28ร—28ร—256
    • Block 4: 3ร— Conv(512) + Pool โ†’ 14ร—14ร—512
    • Block 5: 3ร— Conv(512) + Pool โ†’ 7ร—7ร—512 = 25,088
    • Head: FC(4096) โ†’ FC(4096) โ†’ FC(1000, Softmax).
  • Pros & Cons: Very clean modular design & top-tier transfer learning backbone, but huge memory & ~138M parameters (mostly in FC1: 25,088 ร— 4096 โ‰ˆ 102.7M!).

2.8 Inception (GoogLeNet, 2014) & ResNet (2015)

๐Ÿ”ฅ GUARANTEED PART B QUESTION 6M ยท 9M Sources: MODULE 2.pdf, M 2.3.pdf

1. Inception / GoogLeNet (Google, 2014 โ€” 22 Weight Layers, ~5โ€“7M Params)

  • Core Idea (โ€œWider, Not Just Deeperโ€): Instead of guessing whether a layer needs a 1ร—1, 3ร—3, or 5ร—5 kernel, run all four branches in parallel (1ร—1 Conv, 1ร—1โ†’3ร—3 Conv, 1ร—1โ†’5ร—5 Conv, and 3ร—3 MaxPoolโ†’1ร—1 Conv) inside each Inception Module and concatenate their feature maps depthwise!
  • Why Only ~5โ€“7M Params (12ร— smaller than AlexNet, 20ร— smaller than VGG)?
    1. 1ร—1 Bottleneck Convolutions: Compress input channels before expensive 3ร—3 & 5ร—5 filters.
    2. Global Average Pooling (GAP): Replaces huge dense FC layers at the end by averaging each spatial feature map down to 1 number!
    3. Auxiliary Classifiers: Two side softmax heads plugged into middle layers inject extra gradient signal back to prevent vanishing gradients in 22 layers (discarded at inference).

2. ResNet โ€” Residual Networks (Kaiming He et al., Microsoft, 2015)

  • The Degradation Problem: Simply stacking more layers (e.g., 56-layer plain CNN vs 20-layer plain CNN) caused higher training AND test error (not overfitting โ€” optimization difficulty where deep layers struggle to even approximate an identity mapping!).
  • Residual Learning Solution: Instead of forcing stacked layers to directly fit H(x), reframe them to fit the residual difference F(x) = H(x) โˆ’ x and add the original input via an identity Skip (Shortcut) Connection:
    y = F(x, {Wi}) + x   (or y = F(x) + Wsx when dimensions change)
  • Why Skip Connections Work: Gradient flows directly backwards along the identity path โˆ‚y/โˆ‚x = โˆ‚F/โˆ‚x + 1, preventing vanishing gradients even at 50, 101, or 152 layers (~25.5M params for ResNet-50!).
  • ResNet-50 Architecture: Stem 7ร—7 Conv(64, s=2) โ†’ 3ร—3 MaxPool(s=2) โ†’ Residual Stages [3, 4, 6, 3] using Bottleneck Blocks (1ร—1 reduce โ†’ 3ร—3 conv โ†’ 1ร—1 expand + skip x) across channels 64, 128, 256, 512 โ†’ 7ร—7 Global Avg Pool โ†’ FC 1000 Softmax.
A. INCEPTION MODULE (Multi-Scale Parallel Branches) Previous Layer 1ร—1 Conv 1ร—1 Conv 1ร—1 Conv 3ร—3 MaxPool 3ร—3 Conv 5ร—5 Conv 1ร—1 Conv Depth Concatenation B. RESNET RESIDUAL BLOCK (y = F(x) + x) Input x Weight Layer + ReLU Weight Layer (F(x)) Identity Skip (Shortcut x) + Output: ReLU(F(x) + x)
Figure 2.3: Side-by-Side Architecture of Inception Module (Multi-Branch) and ResNet Identity Skip Block

3. Complete Architecture Comparison Table

Model (Year)DepthParamsInputSignature Breakthrough
AlexNet (2012)8~60M227ร—227ร—3 (224 in paper)ReLU, Dropout 0.5, Multi-GPU, Data Aug, LRN
VGG-16 (2014)16~138M224ร—224ร—3Uniform stacked 3ร—3 Conv + 2ร—2 Pool
Inception (2014)22~5โ€“7M224ร—224ร—3Parallel 1ร—1, 3ร—3, 5ร—5, Pool + 1ร—1 bottleneck + GAP
ResNet-50 (2015)50~25.5M224ร—224ร—3Skip connections y=F(x)+x + 1ร—1โ†’3ร—3โ†’1ร—1 bottlenecks

Module 2 Revision (Aโ€“D): Checklist, Definitions & Diagrams

A. Syllabus Coverage Checklist

  • โœ… CNN Architectural Overview & Motivation (parameter explosion, auto hierarchy, overfitting)
  • โœ… Layers & Filters (Conv, ReLU, Max/Avg Pool, Flatten, FC + Classic 3ร—3 filters + Worked Conv/Pool numericals)
  • โœ… Parameter Sharing & Regularization (Dropout, L1, L2, Data Augmentation, Early Stopping, LRN)
  • โœ… Convolution & Pooling as Infinitely Strong Prior (locality, translation equivariance vs invariance)
  • โœ… Variants of Convolution (10 variants incl. 4D tensor, Valid/Same/Full, Strided, Dilated, Depthwise Sep, Transposed, Locally Connected, Tiled)
  • โœ… Efficient Convolution Methods (uploaded PDF methods + FFT/Winograd/1D/im2col supplement)
  • โœ… Popular Architectures: AlexNet, VGGNet, Inception (GoogLeNet), ResNet

B. Top 3-Mark Definitions

Parameter Sharing

Tying the same kernel weight matrix across all spatial positions of an input feature map, drastically reducing parameters and giving translation equivariance.

Dilated (Atrous) Convolution

Spreads kernel elements apart using spacing/dilation rate d so receptive field grows exponentially without extra weights.

Degradation Problem

Observed when deeper plain networks achieve worse training accuracy than shallower networks because deep Identity mappings are hard to optimize; solved by ResNet skip connections.

Tiled Convolution

Bridges Standard and Locally Connected convolution by cycling periodically through t distinct shared filter sets across spatial steps.

Module 2 Revision (E): Master Formula & Equation Sheet

1. Output Size: O = โŒŠ (W โˆ’ F + 2P) / S โŒ‹ + 1  |  Valid (P=0): mโˆ’k+1  |  Same (S=1): P=(kโˆ’1)/2  |  Full: P=kโˆ’1 โ‡’ m+kโˆ’1
2. Conv Parameters: Params = Nfilters ร— (F ร— F ร— Cin + 1)   (weights across all channels + 1 bias per filter)
3. 4D Tensor Conv: Zi,j,k = โˆ‘l,m,n Vl, j+mโˆ’1, k+nโˆ’1 Ki,l,m,n  |  Residual Block: y = F(x, {Wi}) + x
4. L1 Loss: L + ฮป โˆ‘ |w|  |  L2 Weight Decay Loss: L + ฮป โˆ‘ wยฒ

Module 2 Revision (F): 3M / 6M / 9M Question Bank (With Answers)

Q1 [3M]: Compute output volume shape and parameters when 16 filters of size 3ร—3 (S=1, P=1) act on a 64ร—64ร—3 RGB image.3 Marks
Show Answer

Output W, H = โŒŠ(64โˆ’3+2)/1โŒ‹ + 1 = 64 โ‡’ 64 ร— 64 ร— 16. Params = 16 ร— (3ร—3ร—3 + 1) = 16 ร— 28 = 448.

Q2 [6M]: Differentiate Valid, Same, and Full convolution, plus Standard vs. Tiled vs. Locally Connected layers.6 Marks
Show Answer

State padding rules (P=0 โ†’ mโˆ’k+1; P=(kโˆ’1)/2 โ†’ m; P=kโˆ’1 โ†’ m+kโˆ’1), draw Figure 2.2 comparing full parameter sharing (Standard), cyclic bank of t kernels (Tiled), and unshared 6D tensor weights (Locally Connected).

Q3 [9M]: Compare AlexNet, VGG-16, Inception, and ResNet, explaining how ResNet solves the Degradation problem.9 Marks
Show Answer

Draw Inception parallel branches & ResNet skip block (Figure 2.3), explain Degradation problem (plain 56-layer having higher training error), give y = F(x) + x gradient flow, summarize VGG 3ร—3 stacks (~138M), AlexNet (~60M, ReLU/Dropout/2 GPUs), Inception (~5โ€“7M, 1ร—1 bottleneck + GAP), and include the 4-architecture comparison table.

Module 2 Revision (G): 10-Minute Last-Minute Cheat Sheet

  • Formula: O = โŒŠ(W โˆ’ F + 2P)/SโŒ‹ + 1. Params per filter = FยทFยทCin + 1.
  • Infinitely Strong Prior: Conv enforces local connectivity + translation equivariance; Pool enforces local translation invariance (hard zeros, cannot unlearn).
  • Variants Fast Memory: Valid shrinks; Same keeps; Full grows; Dilated widens FOV via holes; Depthwise+1ร—1 cuts MobileNet FLOPs; Transposed upsamples; Locally Connected drops sharing; Tiled cycles t kernels.
  • Architectures Year Order: AlexNet (2012, 8L, 60M, 227/224, ReLU+Dropout) โ†’ VGG-16 (2014, 16L, 138M, uniform 3ร—3) โ†’ Inception (2014, 22L, 5โ€“7M, parallel branches+1ร—1+GAP) โ†’ ResNet (2015, 50/152L, skip F(x)+x).

Module 2 Revision (H): KTU 2024 Pattern Module 2 Mock Exam (15 Marks)

KTU PCCMT503 โ€” MODULE 2 MOCK TEST (15 Marks)
PART A2 ร— 3 = 6 Marks

1. Why are CNNs preferred over MLPs for images? Illustrate using a 224ร—224ร—3 image connected to 100 hidden neurons. [3M]

2. Compute the 3ร—3 convolved feature map for 5ร—5 input [[1,1,1,0,0],[0,1,1,1,0],[0,0,1,1,1],[0,0,1,1,0],[0,1,1,0,0]] and kernel [[1,0,1],[0,1,0],[1,0,1]] (S=1, P=0). [3M]

PART B (Answer EITHER 3 OR 4)1 ร— 9 = 9 Marks

3. (a) Explain Convolution and Pooling as an Infinitely Strong Prior and describe 4 regularization techniques used in CNNs. [5M]
(b) Compare Valid, Same, Full, Dilated, and Tiled convolutions with output dimension relations. [4M]

โ€” OR โ€”

4. (a) Explain the ResNet architecture, the Degradation problem, and sketch the Bottleneck Residual block (1ร—1 โ†’ 3ร—3 โ†’ 1ร—1). [5M]
(b) Explain the parallel multi-branch structure and 1ร—1 bottleneck optimization of Inception (GoogLeNet). [4M]

Show Complete Mock Exam Solutions
  • Q1: 224ร—224ร—3 = 150,528 ร— 100 = 15,052,800 weights in 1 dense layer; CNN avoids via parameter sharing, local receptive fields & hierarchical learning.
  • Q2: [[4,3,4],[2,4,3],[2,3,4]] (see Worked Numerical 2.2A).
  • Q3: (a) Local connectivity + equivariance + pooling invariance; Dropout/L1/L2/Augmentation/Early Stopping. (b) Padding equations + dilation holes + tiled bank of t kernels.
  • Q4: (a) Degradation = deeper plain nets have higher training error; skip y = F(x) + x lets gradient bypass; ResNet-50 stages [3,4,6,3]. (b) 4 parallel branches + 1ร—1 channel reduction + Global Average Pooling.