Intermediate
28 min read
#CNN#Convolutions#Kernels#Pooling#Receptive Field#PyTorch

11. Convolutional Neural Networks (CNN) Fundamentals

Foundations of spatial computer vision: 2D convolutions, kernels, stride, padding, receptive fields, pooling layers, and full CNN pipelines.

Convolutional Neural Networks: Complete Notes (Beginner to Advanced)


Introduction#

A Convolutional Neural Network (CNN) is a neural network architecture designed to process data with a grid-like structure, especially images.

CNNs are particularly effective for image-related tasks because they can learn spatial patterns while using the same learned filters across different locations of an image.

A typical CNN-based image classification flow is:

Architecture & Data Flow
Image
  |
  v
Convolution
  |
  v
Feature Maps
  |
  v
Pooling
  |
  v
More Convolution + Pooling
  |
  v
Flattening
  |
  v
Fully Connected Layers
  |
  v
Output

The core components covered in this note are:

  • Image Representation
  • Convolution
  • Convolution Kernel
  • Filters
  • Feature Maps
  • Channels
  • Stride
  • Padding
  • Dilation
  • Receptive Field
  • Pooling
  • Max Pooling
  • Average Pooling
  • Flattening
  • Fully Connected Layers

1. Image Representation#

Before understanding convolution, it is important to understand how an image is represented numerically.

A computer does not directly see an image as objects such as:

text
Cat Car Person

Instead, an image is represented as numerical values called pixels.

1.1 Pixels#

A pixel is a single numerical location in an image.

For a grayscale image, each pixel normally contains one intensity value.

For example:

text
0 50 120 30 200 255 10 90 180

The value represents the brightness of the pixel.

A common 8-bit grayscale representation uses:

0 -> black 255 -> white

with values between them representing different shades of gray.

1.2 Grayscale Image Representation#

A grayscale image can be represented as a 2D matrix:

Height × Width

For example:

text
3 × 4 image [ [10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120] ]

The shape is:

(3, 4)

where:

Mathematical Formulation
3 = height
4 = width

1.3 RGB Image Representation#

A color image commonly uses three channels:

text
Red Green Blue

Therefore, an RGB image can be represented as:

Height × Width × 3

For example:

224 × 224 × 3

means:

Mathematical Formulation
Height  = 224
Width   = 224
Channels = 3

The same spatial location contains three values:

(R, G, B)

For example:

(255, 0, 0)

represents a pure red pixel.

1.4 Image Tensors#

Deep learning frameworks commonly represent a batch of images as a tensor.

In PyTorch, a typical image batch has the shape:

(batch_size, channels, height, width)

For example:

(32, 3, 224, 224)

means:

Mathematical Formulation
32    = images in the batch
3     = RGB channels
224   = height
224   = width

This ordering is commonly called NCHW:

Mathematical Formulation
N = batch
C = channels
H = height
W = width

1.5 Why Images Are Not Simply Flattened at the Beginning#

An image contains spatial relationships.

For example, neighboring pixels are usually related to one another.

Consider:

Architecture & Data Flow
Pixel A
   |
   v
Pixel B

These pixels are spatially close.

If the entire image is immediately flattened:

Image -> 1D vector

the explicit 2D spatial arrangement is no longer represented by the tensor structure.

CNNs preserve this spatial structure during convolution and pooling.


2. Convolution#

Convolution is the operation that applies a small learnable matrix over local regions of an input to produce a new representation.

In CNNs, the operation is commonly implemented as a cross-correlation rather than the mathematical convolution operation that flips the kernel. However, the operation is conventionally called convolution in deep learning.

2.1 Basic Idea#

Suppose an image contains:

Input image

and we have a small kernel:

Kernel

The kernel slides across the image.

At each location:

  1. The kernel covers a local region.
  2. Corresponding values are multiplied.
  3. The products are summed.
  4. A bias may be added.
  5. The resulting value becomes one element of the output feature map.

Conceptually:

Architecture & Data Flow
Input
  |
  v
Small local region
  |
  v
Element-wise multiplication with kernel
  |
  v
Sum
  |
  v
Output value

2.2 Simple Numerical Example#

Consider a 3 × 3 input:

text
[ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]

and a 2 × 2 kernel:

text
[ [1, 0], [0, 1] ]

For the first position, the local region is:

text
[ [1, 2], [4, 5] ]

Element-wise multiplication:

(1×1) + (2×0) + (4×0) + (5×1)

Therefore:

Mathematical Formulation
1 + 0 + 0 + 5 = 6

That produces the first value of the output feature map.

The kernel then moves to another location and repeats the same operation.

2.3 General Convolution Output Size#

For a 2D convolution, the output height and width can be calculated using:

Mathematical Formulation
H_out = floor((H_in + 2P - D(K_H - 1) - 1) / S + 1)

W_out = floor((W_in + 2P - D(K_W - 1) - 1) / S + 1)

Where:

Mathematical Formulation
H_in, W_in = input height and width
K_H, K_W   = kernel height and width
P          = padding
S          = stride
D          = dilation

For a square kernel:

Mathematical Formulation
K_H = K_W = K

the formula becomes:

Mathematical Formulation
Output Size = floor((Input Size + 2P - D(K - 1) - 1) / S + 1)

2.4 Convolution in PyTorch#

🐍 Python
import torch import torch.nn as nn conv = nn.Conv2d( in_channels=3, out_channels=16, kernel_size=3 ) X = torch.randn(8, 3, 32, 32) output = conv(X) print("Input shape :", X.shape) print("Output shape:", output.shape)

With default:

Mathematical Formulation
stride = 1
padding = 0
dilation = 1

the spatial dimensions change from:

32 × 32

to:

30 × 30

and the number of output channels is:

16

Therefore:

Input : (8, 3, 32, 32) Output: (8, 16, 30, 30)

3. Convolution Kernel#

A convolution kernel is a small matrix of learnable weights that slides across the input.

For example:

text
3 × 3 kernel [ [w1, w2, w3], [w4, w5, w6], [w7, w8, w9] ]

Each weight is learned during training.

3.1 Kernel Operation#

At a particular spatial location:

text
Input region Kernel [a b c] [w1 w2 w3] [d e f] × [w4 w5 w6] [g h i] [w7 w8 w9]

The output value is:

text
a*w1 + b*w2 + c*w3 + d*w4 + e*w5 + f*w6 + g*w7 + h*w8 + i*w9 + bias

The kernel then moves to the next location.

3.2 Kernel Size#

Common kernel sizes include:

text
1 × 1 3 × 3 5 × 5 7 × 7

A larger kernel covers a larger local region in one operation.

For example:

3 × 3 -> smaller local region 5 × 5 -> larger local region

Kernel size affects:

  • receptive field
  • parameter count
  • computation
  • output dimensions

3.3 Kernel Is Learnable#

The kernel values are not normally manually designed for a trained CNN.

Initially, they are initialized with some values and then updated during training.

Architecture & Data Flow
Initial Kernel
      |
      v
Training
      |
      v
Updated Kernel
      |
      v
Useful Feature Detector

The network therefore learns which local patterns are useful for the task.


4. Filters#

A filter is the complete set of kernel weights used to produce one output channel.

For a single-channel input, a filter may look like:

3 × 3

For a multi-channel input, the filter extends across all input channels.

For example, if the input has 3 channels and the kernel size is 3 × 3, one filter has shape:

3 × 3 × 3

or:

(in_channels, kernel_height, kernel_width)

4.1 Filter Producing One Feature Map#

One filter scans the input and produces one output feature map.

Architecture & Data Flow
Input
  |
  v
Filter 1
  |
  v
Feature Map 1

Another filter:

Architecture & Data Flow
Input
  |
  v
Filter 2
  |
  v
Feature Map 2

Therefore:

Mathematical Formulation
Number of filters = Number of output channels

4.2 Multiple Filters#

Suppose:

Mathematical Formulation
Input channels = 3
Number of filters = 16

The convolution uses 16 filters.

Each filter produces one feature map.

Therefore:

Architecture & Data Flow
16 filters
      |
      v
16 feature maps
      |
      v
16 output channels

4.3 Filters Learn Different Patterns#

Different filters can learn different useful patterns.

Conceptually:

Architecture & Data Flow
Filter 1 -> edge-like pattern
Filter 2 -> another orientation
Filter 3 -> texture-like pattern
Filter 4 -> another local pattern
...

The exact patterns are learned from data rather than manually assigned.


5. Feature Maps#

A feature map is the spatial output produced by applying one filter across the input.

It indicates where the pattern detected by that filter is strongly present.

5.1 Feature Map Example#

Suppose a filter responds strongly to a particular edge.

The resulting feature map might contain larger values where that edge occurs:

text
[ [0.1, 0.2, 0.1], [0.2, 2.5, 0.3], [0.1, 0.4, 3.1] ]

Higher values indicate stronger responses to the learned pattern.

5.2 Multiple Feature Maps#

If a convolution uses 32 filters:

Architecture & Data Flow
Filter 1 -> Feature Map 1
Filter 2 -> Feature Map 2
Filter 3 -> Feature Map 3
...
Filter 32 -> Feature Map 32

The feature maps are stacked together to form the output tensor.

Therefore:

Mathematical Formulation
Number of feature maps = Number of filters = Number of output channels

5.3 Feature Map Size#

The spatial size of a feature map depends on:

  • input size
  • kernel size
  • stride
  • padding
  • dilation

For example:

text
Input: 32 × 32 Kernel: 3 × 3 Stride: 1 Padding: 0 Dilation: 1 Feature map: 30 × 30

6. Channels#

A channel represents one component of the data at each spatial location.

6.1 Input Channels#

A grayscale image normally has:

1 channel

An RGB image has:

3 channels
Architecture & Data Flow
RGB Image
 |
 +-- Red channel
 +-- Green channel
 +-- Blue channel

6.2 Output Channels#

A convolution can produce any chosen number of output channels.

For example:

🐍 Python
nn.Conv2d( in_channels=3, out_channels=64, kernel_size=3 )

means:

Mathematical Formulation
Input channels  = 3
Output channels = 64

The layer contains 64 filters.

Each filter produces one feature map.

Therefore:

Architecture & Data Flow
64 filters
      |
      v
64 feature maps
      |
      v
64 output channels

6.3 Channels Through a CNN#

A typical CNN may transform the number of channels like this:

Architecture & Data Flow
Input image
3 channels
     |
     v
Conv
32 channels
     |
     v
Conv
64 channels
     |
     v
Conv
128 channels

The spatial dimensions may decrease while the number of channels increases.


7. Stride#

Stride specifies how far the kernel moves between consecutive positions.

7.1 Stride = 1#

With:

Mathematical Formulation
stride = 1

the kernel moves one pixel at a time:

Architecture & Data Flow
Position 1
   |
   v
Position 2
   |
   v
Position 3

This produces more spatial output positions.

7.2 Stride = 2#

With:

Mathematical Formulation
stride = 2

the kernel moves two pixels at a time:

Architecture & Data Flow
Position 1
     |
     v
Position 3
     |
     v
Position 5

This produces a smaller spatial output.

7.3 Effect on Output Size#

Example:

Mathematical Formulation
Input = 32 × 32
Kernel = 3 × 3
Padding = 0

With:

Mathematical Formulation
Stride = 1

output:

30 × 30

With:

Mathematical Formulation
Stride = 2

output:

15 × 15

using the standard output-size formula with floor.

7.4 Stride in PyTorch#

🐍 Python
import torch import torch.nn as nn conv = nn.Conv2d( in_channels=3, out_channels=16, kernel_size=3, stride=2 ) X = torch.randn(4, 3, 32, 32) output = conv(X) print(output.shape)

The spatial dimensions are reduced because the filter moves in larger steps.


8. Padding#

Padding adds extra values around the boundary of the input before convolution.

The most common padding value is:

0

which is called zero padding.

8.1 Why Padding Is Used#

Without padding, the spatial dimensions generally become smaller after convolution.

For example:

text
Input: 32 × 32 Kernel: 3 × 3 Stride: 1 Padding: 0 Output: 30 × 30

Padding can preserve more spatial information near the boundaries and control the output size.

8.2 Example of Zero Padding#

Original:

text
[ [1, 2], [3, 4] ]

With one-pixel zero padding:

text
[ [0, 0, 0, 0], [0, 1, 2, 0], [0, 3, 4, 0], [0, 0, 0, 0] ]

8.3 Padding and Output Size#

For:

Mathematical Formulation
Kernel = 3
Stride = 1
Dilation = 1

using:

Mathematical Formulation
Padding = 1

gives:

Mathematical Formulation
Output Size = Input Size

For example:

32 × 32 -> 32 × 32

This is commonly called same padding for this particular configuration.

8.4 Padding in PyTorch#

🐍 Python
import torch.nn as nn conv = nn.Conv2d( in_channels=3, out_channels=32, kernel_size=3, stride=1, padding=1 )

For an input of:

(batch, 3, 32, 32)

the output spatial dimensions remain:

32 × 32

9. Dilation#

Dilation controls the spacing between the elements of a convolution kernel.

A normal convolution has:

Mathematical Formulation
dilation = 1

With a larger dilation value, gaps are introduced between kernel elements.

9.1 Normal 3 × 3 Kernel#

With:

Mathematical Formulation
kernel = 3 × 3
dilation = 1

the kernel covers a 3 × 3 region.

text
XXX XXX XXX

9.2 Dilated 3 × 3 Kernel#

With:

Mathematical Formulation
kernel = 3 × 3
dilation = 2

the kernel elements are spaced apart:

text
X.X.X ..... X.X.X ..... X.X.X

The effective region covered is:

5 × 5

even though the kernel still contains only:

Mathematical Formulation
3 × 3 = 9

learnable weights per input channel.

9.3 Effective Kernel Size#

The effective kernel size is:

Mathematical Formulation
K_eff = K + (K - 1)(D - 1)

or equivalently:

Mathematical Formulation
K_eff = 1 + (K - 1)D

For:

Mathematical Formulation
K = 3
D = 2

we get:

Mathematical Formulation
K_eff = 1 + (3 - 1) × 2
      = 5

Therefore, a 3 × 3 kernel with dilation 2 covers the same spatial extent as a 5 × 5 kernel while retaining only 9 kernel positions.

9.4 Dilation in PyTorch#

🐍 Python
import torch.nn as nn conv = nn.Conv2d( in_channels=3, out_channels=32, kernel_size=3, dilation=2 )

Dilation can increase the spatial area seen by a filter without proportionally increasing the number of kernel weights.


10. Receptive Field#

The receptive field of a neuron is the region of the original input that can influence that neuron's value.

10.1 Basic Example#

For a single convolution:

Architecture & Data Flow
Input image
     |
     v
3 × 3 convolution
     |
     v
Output neuron

one output value depends on a:

3 × 3

region of the input, assuming:

Mathematical Formulation
kernel = 3
dilation = 1

Therefore, its receptive field is:

3 × 3

10.2 Receptive Field Across Multiple Layers#

Consider two consecutive 3 × 3 convolutions with stride 1 and no dilation.

First layer:

Mathematical Formulation
Receptive field = 3 × 3

The second layer sees a 3 × 3 region of the first layer's outputs.

Each of those first-layer outputs already depends on a 3 × 3 region of the original image.

Therefore, the second-layer output depends on a:

5 × 5

region of the original image.

Conceptually:

Architecture & Data Flow
Input
  |
  v
3 × 3 Conv
  |
  v
3 × 3 Conv
  |
  v
Effective receptive field = 5 × 5

10.3 Receptive Field Calculation#

For a sequence of layers, the receptive field can be tracked using:

Mathematical Formulation
r_l = r_(l-1) + (K_l - 1) × D_l × j_(l-1)

where:

Mathematical Formulation
r_l = receptive field at layer l
K_l = kernel size
D_l = dilation
j_(l-1) = spacing between neighboring receptive-field positions at the previous layer

The jump can be updated using:

Mathematical Formulation
j_l = j_(l-1) × S_l

where:

Mathematical Formulation
S_l = stride of the current layer

Starting from the input:

Mathematical Formulation
r_0 = 1
j_0 = 1

10.4 Why Receptive Field Matters#

A small receptive field allows a neuron to focus on local information.

A larger receptive field allows it to incorporate information from a larger portion of the original input.

Conceptually:

Architecture & Data Flow
Early layers
     |
     v
Small local patterns
     |
     v
Larger receptive fields
     |
     v
More spatial context

11. Pooling#

Pooling is a downsampling operation that reduces the spatial dimensions of feature maps.

For example:

Architecture & Data Flow
32 × 32
   |
   v
16 × 16

Pooling operates over local regions and summarizes the values in those regions.

11.1 Why Pooling Is Used#

Pooling can:

  • reduce spatial dimensions
  • reduce computation in later layers
  • reduce the amount of spatial information that must be processed
  • provide some tolerance to small spatial changes

11.2 Pooling Window#

A common pooling configuration is:

Mathematical Formulation
2 × 2 pooling window
stride = 2

The window examines:

2 × 2

regions and moves two positions at a time.

Example:

text
Input: [ [1, 2, 3, 4], [5, 6, 7, 8], [9,10,11,12], [13,14,15,16] ]

A 2 × 2 pooling operation with stride 2 produces a:

2 × 2

output.

11.3 Pooling Does Not Usually Learn Weights#

Unlike convolution:

Convolution -> learnable weights Pooling -> fixed aggregation operation

For example, max pooling selects the maximum value and average pooling calculates the average.


12. Max Pooling#

Max pooling selects the maximum value from each pooling region.

Consider:

text
[ [1, 5], [3, 2] ]

The maximum is:

5

Therefore:

2 × 2 region -> 5

12.1 Example#

Input:

text
[ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13,14, 15, 16] ]

Using:

Mathematical Formulation
kernel = 2 × 2
stride = 2

the output is:

text
[ [ 6, 8], [14, 16] ]

because:

Mathematical Formulation
max(1,2,5,6)     = 6
max(3,4,7,8)     = 8
max(9,10,13,14)  = 14
max(11,12,15,16) = 16

12.2 Max Pooling in PyTorch#

🐍 Python
import torch import torch.nn as nn pool = nn.MaxPool2d( kernel_size=2, stride=2 ) X = torch.randn(4, 32, 28, 28) output = pool(X) print("Input shape :", X.shape) print("Output shape:", output.shape)

The output spatial dimensions become:

28 × 28 -> 14 × 14

while the number of channels remains:

32

Therefore:

Architecture & Data Flow
(4, 32, 28, 28)
        ->
(4, 32, 14, 14)

13. Average Pooling#

Average pooling calculates the average value of each local pooling region.

For:

text
[ [1, 5], [3, 2] ]

the average is:

Mathematical Formulation
(1 + 5 + 3 + 2) / 4
= 11 / 4
= 2.75

13.1 Example#

Using the same input:

text
[ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13,14, 15, 16] ]

with a 2 × 2 window and stride 2:

text
[ [3.5, 5.5], [11.5, 13.5] ]

13.2 Average Pooling in PyTorch#

🐍 Python
import torch import torch.nn as nn pool = nn.AvgPool2d( kernel_size=2, stride=2 ) X = torch.randn(4, 32, 28, 28) output = pool(X) print("Input shape :", X.shape) print("Output shape:", output.shape)

The spatial dimensions are reduced while the number of channels remains unchanged.

13.3 Max Pooling vs Average Pooling#

PropertyMax PoolingAverage Pooling
OperationSelects maximumCalculates average
Preserves strong responsesYesLess directly
OutputLargest value in regionMean value in region
Learnable parametersNoNo
Common purposePreserve strong local activationsSummarize local information

14. Flattening#

Flattening converts a multi-dimensional feature tensor into a one-dimensional feature vector for each sample.

A CNN may produce:

(batch_size, channels, height, width)

For example:

(32, 64, 7, 7)

Before passing this representation into a standard fully connected layer, it can be flattened to:

(32, 64 × 7 × 7)

which becomes:

(32, 3136)

14.1 What Flattening Does#

Flattening does not perform a mathematical feature transformation by itself.

It changes the representation from:

64 × 7 × 7

to:

3136

for each sample.

The values themselves are preserved; their dimensions are rearranged into one vector.

14.2 Flattening Example#

Suppose one image produces:

text
2 channels × 2 height × 3 width

The tensor contains:

Mathematical Formulation
2 × 2 × 3 = 12 values

Flattening converts it into:

[12 values]

14.3 Flattening in PyTorch#

🐍 Python
import torch X = torch.randn(8, 64, 7, 7) flattened = torch.flatten(X, start_dim=1) print("Before flattening:", X.shape) print("After flattening :", flattened.shape)

Output:

Before flattening: torch.Size([8, 64, 7, 7]) After flattening : torch.Size([8, 3136])

start_dim=1 preserves the batch dimension and flattens all remaining dimensions.


15. Fully Connected Layers#

A fully connected layer, also called a dense layer, connects every input feature to every output neuron.

After convolution and pooling extract spatial features, fully connected layers can use the resulting feature representation for the final task.

A traditional CNN classification pipeline can therefore look like:

Architecture & Data Flow
Image
  |
  v
Convolution
  |
  v
Feature Maps
  |
  v
Pooling
  |
  v
Convolution
  |
  v
Pooling
  |
  v
Flatten
  |
  v
Fully Connected Layer
  |
  v
Output

15.1 Dense Layer Operation#

For an input vector x:

Mathematical Formulation
z = xW + b

where:

Mathematical Formulation
x = input vector
W = weight matrix
b = bias
z = output

Each output neuron receives information from every input feature.

15.2 Connecting Flattened CNN Features#

Suppose a CNN produces:

64 × 7 × 7

features.

Flattening gives:

3136

features.

A fully connected layer with 128 neurons can then be defined as:

🐍 Python
nn.Linear(3136, 128)

The parameter count is:

3136 × 128 + 128

which equals:

401,536 parameters

This demonstrates why fully connected layers can contain a large number of parameters.

15.3 Fully Connected Layer in PyTorch#

🐍 Python
import torch import torch.nn as nn fc = nn.Linear(3136, 128) X = torch.randn(8, 3136) output = fc(X) print("Input shape :", X.shape) print("Output shape:", output.shape)

Output:

Input shape : torch.Size([8, 3136]) Output shape: torch.Size([8, 128])

15.4 CNN with Flattening and Fully Connected Layer#

🐍 Python
import torch import torch.nn as nn class SimpleCNN(nn.Module): def __init__(self): super().__init__() self.features = nn.Sequential( nn.Conv2d(3, 32, kernel_size=3, padding=1), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(32, 64, kernel_size=3, padding=1), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2) ) self.classifier = nn.Sequential( nn.Flatten(), nn.Linear(64 * 8 * 8, 128), nn.ReLU(), nn.Linear(128, 10) ) def forward(self, x): x = self.features(x) x = self.classifier(x) return x model = SimpleCNN() X = torch.randn(8, 3, 32, 32) output = model(X) print("Output shape:", output.shape)

The spatial dimensions flow as:

text
Input: 3 × 32 × 32 Conv: 32 × 32 × 32 Max Pool: 32 × 16 × 16 Conv: 64 × 16 × 16 Max Pool: 64 × 8 × 8 Flatten: 4096 Fully Connected: 128 Output: 10

The important structural flow is:

Architecture & Data Flow
Image
  |
  v
Convolution
  |
  v
Feature Maps
  |
  v
Pooling
  |
  v
Convolution
  |
  v
Feature Maps
  |
  v
Pooling
  |
  v
Flattening
  |
  v
Fully Connected Layers
  |
  v
Output

Summary Table#

ConceptCore Idea
Image RepresentationImages are represented as numerical pixel tensors
ConvolutionSlides local learnable weights across the input to produce spatial features
Convolution KernelSmall matrix/tensor of weights applied to local input regions
FiltersComplete learned kernels that produce output channels
Feature MapsSpatial outputs produced by filters
ChannelsSeparate feature dimensions at each spatial location
StrideStep size by which a kernel moves across the input
PaddingAdditional border values added around the input
DilationSpacing between kernel elements
Receptive FieldRegion of the original input that can influence an output value
PoolingFixed local operation used to downsample feature maps
Max PoolingSelects the maximum value from each local region
Average PoolingCalculates the average value of each local region
FlatteningConverts spatial feature tensors into vectors
Fully Connected LayersDense layers that connect every input feature to every output neuron

Quick Recap#

  1. An image is represented numerically as pixels arranged into spatial dimensions and channels.
  2. Convolution applies local learnable weights across an input.
  3. A kernel is the small set of weights used at each spatial location.
  4. A filter spans all input channels and produces one output feature map.
  5. Multiple filters produce multiple feature maps, which become output channels.
  6. Stride controls how far the kernel moves at each step.
  7. Padding adds borders around the input and helps control spatial dimensions.
  8. Dilation increases the spatial area covered by a kernel without proportionally increasing its number of weights.
  9. The receptive field describes how much of the original input can influence a particular output.
  10. Pooling reduces spatial dimensions using fixed aggregation operations.
  11. Max pooling preserves the strongest activation in a region.
  12. Average pooling summarizes a region using its mean.
  13. Flattening converts convolutional feature maps into a vector.
  14. Fully connected layers use that vector for subsequent dense transformations, often near the end of a traditional CNN.
Knowledge Checkpoint

11. CNN Fundamentals Checkpoint

Q1.What two core inductive biases make CNNs drastically more efficient than MLPs for spatial images?
ALocal connectivity (sparse interactions) and weight sharing (translation equivariance).
BRecurrent memory loops and self-attention.
CSorting pixels by luminance and discarding colors.
DZero initialization and L1 regularization.
Q2.For an input image of size W, kernel size K, padding P, and stride S, what is the formula for output spatial dimension W_out?
AW_out = floor((W - K + 2*P) / S) + 1
BW_out = (W * S) / K + P
CW_out = W - K + P
DW_out = (W + K) * 2 / S
Q3.What is the primary function of Max Pooling layers in CNN architectures?
ADownsample spatial resolution to reduce computational cost, increase receptive field size, and provide minor translation invariance.
BIncrease the number of feature channels by 2x.
CCompute gradients during the backward pass.
DApply non-linear ReLU transformations to channels.
Track Your Learning

Finished studying this notebook?

Mark this guide as completed to update your course progress roadmap.