๐Ÿ–ผ๏ธ Convolutional Neural Networks

294 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# ๐Ÿ–ผ๏ธ Convolutional Neural Networks ## 1. ๐ŸŽฏ Learning Objectives - Compute convolution output dimensions: $(n+2p-f)/s + 1$ - Explain the purpose of padding and stride - Compare pooling types: max vs average - Identify key architectural innovations in LeNet, AlexNet, VGG ## 2.

๐Ÿ–ผ๏ธ Convolutional Neural Networks

1. ๐ŸŽฏ Learning Objectives

  • Compute convolution output dimensions: (n+2pโˆ’f)/s+1(n+2p-f)/s + 1
  • Explain the purpose of padding and stride
  • Compare pooling types: max vs average
  • Identify key architectural innovations in LeNet, AlexNet, VGG

2. ๐Ÿ“– Core Content

3.1 Convolution Operation

A convolution applies a kernel (filter) across the input:
(Iโˆ—K)(i,j)=โˆ‘mโˆ‘nI(i+m,j+n)โ‹…K(m,n)(I * K)(i,j) = \sum_m \sum_n I(i+m, j+n) \cdot K(m,n)

3.2 Output Size Formula

Hout=โŒŠHin+2pโˆ’fs+1โŒ‹H_{out} = \left\lfloor \frac{H_{in} + 2p - f}{s} + 1 \right\rfloor
Where:
  • HinH_{in}: Input height
  • ff: Filter/kernel size
  • pp: Padding
  • ss: Stride Example: Input 32ร—32, filter 5ร—5, padding 0, stride 1: (32+0-5)/1+1 = 28. Output: 28ร—28.

3.3 Padding

  • Valid padding (p=0): No padding. Output smaller than input.
  • Same padding: p=(fโˆ’1)/2p = (f-1)/2. Output same size as input.
  • Only possible with odd filter sizes (3, 5, 7...).

3.4 Stride

Stride s > 1 downsamples the input. Higher stride = smaller output.

3.5 Pooling

Max pooling: Take maximum value in each window. Average pooling: Take average value in each window. Typically 2ร—2 with stride 2: halves spatial dimensions.

3.6 CNN Architectures

ArchitectureYearKey InnovationParameters
LeNet-51998First successful CNN60K
AlexNet2012Deep CNN + ReLU + Dropout + GPU60M
VGG-162014Very deep (16 layers), 3ร—3 conv only138M
GoogLeNet2014Inception modules, efficient4M
ResNet2015Skip connections (residual blocks)25M

4. ๐Ÿ“ Practice Questions

Q1: Input 224ร—224ร—3, filters 64 of size 7ร—7, padding 3, stride 2. Output size?
Answer: H_out = (224 + 2ร—3 - 7)/2 + 1 = (224+6-7)/2 + 1 = 223/2 + 1 = 111.5 + 1 = 112 (assuming integer division). Actually: (224+6-7)/2 + 1 = 223/2 + 1 = 111.5 + 1 = 112.5 โ†’ floor 112. Output: 112ร—112ร—64. Join Discord PreviousCNN OperationsNextCNN Architectures
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.