Pathubs Logo Mark
PATHUBSFREE CAREER ROADMAPS
HomeExploreDiscoverCompare βš–οΈMy Progress πŸ“ŠSupport
Student Support & Feedback

Have Questions or Need Help?

Have questions, feedback, or suggestions for new roadmaps and interactive tools? Reach out to our team β€” we review every message to make practical learning better for everyone.

supportpathubs@gmail.com
Pathubs

Pathubs is an interactive learning platform that combines structured career roadmaps, topic-by-topic learning, and hands-on practice β€” 100% free with no paywalls.

Popular Careers

  • Frontend Development
  • Backend Development
  • AI & LLM Engineering
  • Full Stack Web Dev
  • Data Analytics

Platform Tools

  • Career Discovery Quiz
  • Compare Careers

Contact & Info

  • About Us
  • supportpathubs@gmail.com
  • Support Pathubs

Β© 2026 Pathubs. All Rights Reserved. Structured learning, practical content, and hands-on practice for learners worldwide.

AboutPrivacy PolicyTerms & ConditionsSitemapRobots
Home/AI Engineering/Phase 05: Deep Learning/Convolutional Neural Networks (CNN)
AI Engineering β€’ Neural Architectures

Convolutional Neural Networks (CNNs)

Master visual deep learning from spatial foundations to production PyTorch 2.6+ engineering. Understand why dense layers fail on images, master the (N, C, H, W) tensor hierarchy, calculate multi-channel 3D convolutions, derive output shapes, inspect intermediate feature maps, and train robust vision models.

Track: Computer Vision & Deep Learning
Level: Intermediate to Advanced
Est. Time: 90–120 Minutes
Runtime: PyTorch 2.6+ / In-Browser Simulators
Curriculum Table of Contents
01 Why CNNs Exist & Spatial Inductive Bias02 Image Tensors & (N, C, H, W) Layout03 Convolution Mechanics & Sliding Window04 Multi-Channel Filters & nn.Conv2d Weights05 Stride, Padding & Output Shape Derivation06 Pooling & Downsampling Strategies07 Receptive Fields & Feature Hierarchy08 Building a Modular CNN in PyTorch09 Interactive CNN Training Simulator10 Feature Maps & 8 PyTorch Debugging Labs11 Mini-Project: Image Classification Pipeline12 Production Pitfalls & AI Engineering Quiz
01

Why CNNs Exist: The Problem with Flattening Images

How spatial inductive biases solve the catastrophic parameter explosion of fully connected networks.

In previous modules, you built Multilayer Perceptrons (MLPs) using fully connected linear layers (nn.Linear). In an MLP, every input feature connects to every neuron. While this architecture works well for tabular records, it fails catastrophically when applied to raw visual data.

The Dense / Flattening Trap

Suppose you feed a modest 1000 Γ— 1000 pixel RGB image to an MLP with 1,024 hidden neurons in its first layer. Flattening the image creates a 1D vector of length 3,000,000. The weight matrix for just that first layer requires:

3,000,000 inputs * 1,024 neurons = 3,072,000,000 parameters (~12.3 GB VRAM)

A single layer requires over 3 billion floating-point weights before doing any meaningful processing. This leads directly to out-of-memory errors and extreme overfitting.

The Convolutional Solution

Instead of connecting every pixel to every neuron, a CNN slides a small shared kernel (e.g. 3 Γ— 3 = 9 weights) across the entire 2D image grid.

32 filters * (3 channels * 3 * 3 + 1 bias) = 896 parameters (~3.5 KB VRAM)

A 32-filter convolutional layer requires only 896 parametersβ€”regardless of whether the input image is 32 Γ— 32 or 4K resolution!

The Three Core Principles of Convolutional Networks

1. Spatial Locality

Pixels that are close together are strongly correlated. An edge, corner, or texture depends on adjacent pixels, not on a pixel 500 rows away. CNNs restrict connections to local receptive fields.

2. Parameter Sharing

A kernel that detects a vertical edge at the top-left corner can detect the same vertical edge at the bottom-right corner. The same weights are reused across every spatial coordinate.

3. Hierarchical Abstraction

Early layers capture low-level primitive edges and gradients. Intermediate layers combine edges into corners, curves, and textures. Deep layers synthesize textures into object parts and semantic concepts.

Engineering Reality: Translation Robustness vs Strict Invariance

Do not assume CNNs are inherently 100% translation invariant. Convolutions are mathematically translation equivariant (shifting the input image by 2 pixels shifts the output feature map by 2 pixels). Downsampling (pooling and striding) provides approximate local shift tolerance, but large shifts, rotations, or scale changes still require data augmentation (e.g. random cropping, flipping).

PropertyFully Connected (MLP)Convolutional Neural Network (CNN)
Input TopologyFlat 1D vector (destroys 2D pixel coordinates)Preserves native 2D/3D spatial grid (H, W, C)
Parameter ScalingScales quadratically with image resolution (H Γ— W Γ— Neurons)Completely independent of image resolution; depends only on kernel size and channels
Weight ReusabilityZero sharing; each pixel location has unique weightsMassive sharing; the same kernel convolves the entire spatial surface
Translation AwarenessMust re-learn an object independently at every coordinateNaturally detects features regardless of spatial coordinate
Overfitting TendencyExtreme on images due to billions of redundant weightsHeavily regularized by spatial weight sharing
02

Image Tensors and the (N, C, H, W) Layout

Mastering PyTorch batch tensor dimensions, channel mechanics, and memory footprints.

In PyTorch, all 2D convolutional layers expect input tensors formatted in the strict 4-dimensional layout: (N, C, H, W).

PyTorch Dimension Breakdown

  • N (Batch Size): Number of independent images processed in parallel.
  • C (Channels): Number of feature planes. 1 for grayscale, 3 for RGB (Red, Green, Blue), or 64/128/512 for latent feature maps deeper in the network.
  • H (Height): Number of pixel rows in the spatial grid.
  • W (Width): Number of pixel columns in the spatial grid.

Contrast: NumPy / OpenCV (H, W, C)

Libraries like OpenCV, Pillow, and Matplotlib store images in (Height, Width, Channels) format. Before passing an image to PyTorch, you must convert it to (Channels, Height, Width) and add the batch dimension.

# NumPy / OpenCV: (H, W, C) -> PyTorch: (1, C, H, W)
tensor = torch.from_numpy(np_img).permute(2, 0, 1).unsqueeze(0).float()

Interactive Tool: Image Tensor Shape Explorer

Live Dimension Calculator

Adjust the sliders below to see how batch size, channel depth, and image resolution dictate the total tensor elements and uncompressed float32 memory consumption:

PyTorch Tensor Shape: torch.Size([16, 3, 128, 128])
Total Float Elements: 786,432
Memory Footprint (float32): 3.00 MB
Memory stride progression: Element stride across Width = 1 β€’ Height stride = 128 β€’ Channel stride = 16384 β€’ Batch stride = 49152
03

Convolution: The Core Mathematical Mechanics

Walking through genuine discrete 2D cross-correlation arithmetic step-by-step.

In machine learning literature and deep learning frameworks, the operation performed by nn.Conv2d is technically 2D cross-correlation (a convolution without flipping the kernel horizontally and vertically). Since kernel weights are learned through gradient descent, flipping the kernel is mathematically equivalent and omitted for computational speed.

The 2D Discrete Convolution Formula:
Output[i, j] = βˆ‘m=0kH-1 βˆ‘n=0kW-1Input[i + m, j + n] Γ— Kernel[m, n] + Bias
Where (i, j) is the coordinate of the output feature map, (m, n) indexes the kernel grid, and Bias is a single learnable scalar per filter.

Interactive Tool: 2D Convolution Matrix Explorer

Real Matrix Computation

Below is a real 5 Γ— 5 input matrix (representing a bright vertical stripe on the left) and a 3 Γ— 3 kernel. Click any cell in the output feature map or use the position controls to inspect the exact dot product and summation.

Active Filter: Detects sharp transitions from light to dark along the vertical axis.

Input Matrix (5 Γ— 5)
10
10
10
0
0
10
10
10
0
0
10
10
10
0
0
10
10
10
0
0
10
10
10
0
0
Γ—
Kernel (3 Γ— 3)
-1
0
1
-2
0
2
-1
0
1
=
Output Feature Map (3 Γ— 3)
0
-40
-40
0
-40
-40
0
-40
-40
Step Computation for Output[0, 0]:
(10 Γ— -1) + (10 Γ— 0) + (10 Γ— 1) + (10 Γ— -2) + (10 Γ— 0) + (10 Γ— 2) + (10 Γ— -1) + (10 Γ— 0) + (10 Γ— 1) + bias(0) = 0
Notice how the vertical edge kernel outputs a high response (e.g. 40) when centered over the boundary between 10s and 0s, and outputs 0 on uniform flat regions!
04

Filters, Channels, and nn.Conv2d Weight Shapes

Why multi-channel filters are 3D tensors, and how PyTorch stores convolutional weights.

A common misconception among beginners is that a convolutional filter is just a 2D matrix. In reality, a single filter operating on a multi-channel input is a 3D volume of shape (in_channels, kernel_height, kernel_width).

Multi-Channel Convolution Anatomy

When an RGB image (3 channels) enters nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3):

  1. The layer creates 16 distinct filters.
  2. Each filter possesses 3 separate 2D kernels (one dedicated for Red, one for Green, one for Blue): shape (3, 3, 3).
  3. Each 2D kernel convolves its corresponding input channel.
  4. The 3 resulting 2D matrices are summed together elementwise across channels.
  5. A single scalar bias is added to produce ONE 2D feature map.
  6. Since there are 16 filters, this process produces 16 stacked output feature maps: shape (N, 16, H_out, W_out).

PyTorch nn.Conv2d Tensor Weights

PyTorch stores the learnable weights of nn.Conv2d in a single 4-dimensional parameter tensor:

Python / PyTorch
import torch.nn as nn

conv = nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, bias=True)

# Weight tensor shape: (out_channels, in_channels, kH, kW)
print(conv.weight.shape)  # torch.Size([32, 3, 3, 3])

# Bias tensor shape: (out_channels,)
print(conv.bias.shape)    # torch.Size([32])
Exact Parameter Counting Formula

For any nn.Conv2d layer with bias=True:
Total Parameters = out_channels Γ— (in_channels Γ— kH Γ— kW + 1)
Example with 3 input channels, 64 output channels, and 3Γ—3 kernel:
64 Γ— (3 Γ— 3 Γ— 3 + 1) = 64 Γ— 28 = 1,792 parameters.

05

Stride, Padding, and Output Shape Derivation

Mastering the mathematical formula that governs spatial transformations in PyTorch.

When designing a CNN, you must know the exact spatial dimension of the output tensor after every convolution. PyTorch documentation specifies the exact formula for output height (and identically for width):

Official PyTorch Spatial Output Formula:
Hout = ⌊ ( Hin+ 2 Γ— P βˆ’ D Γ— (K βˆ’ 1) βˆ’ 1 ) / S + 1 βŒ‹
β€’ Hin: Input height β€’ P: Padding on each border β€’ K: Kernel size β€’ S: Stride β€’ D:Dilation rate (default 1) β€’ ⌊ βŒ‹: Floor division (integer truncation).

1. Stride (S)

The step size in pixels the kernel shifts across each step. Stride 1 evaluates every adjacent pixel. Stride 2 shifts by 2 pixels, roughly halving the spatial output resolution.

2. Padding (P)

Zero-padding added to outer borders. With padding='same' and stride 1, the output spatial size matches the input. padding='valid' means P = 0.

3. Dilation (D)

Spacing between kernel points (atrous convolution). Dilation 2 inserts a gap of 1 between kernel weights, expanding the receptive field without adding parameters.

Interactive Tool: CNN Shape & Parameter Calculator

PyTorch 2.6+ Verified
OUTPUT SPATIAL SHAPE:
(16, 32, 32)
Height: 32 px β€’ Width: 32 px
WEIGHT TENSOR GEOMETRY:
torch.Size([16, 3, 3, 3])
Weights: 432
TOTAL PARAMETER COUNT:
448 params
Biases: 16
ESTIMATED FLOPs / IMAGE:
0.88 MFLOPs
Multiply-Accumulate operations
06

Pooling & Downsampling: MaxPool2d, AvgPool2d & Adaptive Pooling

Reducing spatial resolution, managing computational load, and increasing receptive fields.

As representations progress deeper through a CNN, high spatial resolution becomes less important than detecting high-level concepts. Pooling operations downsample feature maps along the spatial dimensions (H, W) while leaving the channel dimension (C) completely untouched.

MaxPool2d(kernel_size=2, stride=2)

Extracts the maximum activationin each 2Γ—2 patch. Preserves the most salient feature response (e.g. sharp edge presence) while discarding weak background noise.

AvgPool2d(kernel_size=2, stride=2)

Computes the arithmetic mean of all activations in the window. Smooths feature representations, often used in global average pooling before classification.

AdaptiveAvgPool2d((target_H, target_W))

Dynamically calculates kernel size and stride so the output matches the target shape regardless of input size. AdaptiveAvgPool2d((1, 1)) is the modern standard to decouple classifiers from input resolution.

Interactive Tool: Pooling Explorer

2Γ—2 Downsampling
Input Activations (4 Γ— 4)
12
20
30
4
8
32
16
2
45
10
80
25
5
18
90
60
→ MaxPool2d→
Output Map (2 Γ— 2)
32
30
45
90
Calculation for Selected 2Γ—2 Quadrant:
Patch values: [12, 20, 8, 32]
Operation: max(12, 20, 8, 32) = 32
07

Receptive Fields and the Feature Hierarchy

How shallow local kernels synthesize into global semantic object detectors.

The receptive fieldof a neuron is the specific region in the original input image that can influence that neuron's activation. While Layer 1 only observes a tiny 3Γ—3 pixel patch, Layer 2 looks at a 3Γ—3 patch of Layer 1's activationsβ€”which in turn look at a 5Γ—5 patch of the raw image.

Visualizing Receptive Field Progression

Layer 1: Local Edges

Receptive Field: 3 Γ— 3 px
Detects horizontal and vertical boundaries, color gradients, and tiny orientation edges.

Layer 2: Textures & Corners

Receptive Field: 5 Γ— 5 px
Combines multiple adjacent edges to recognize corners, curves, repetitive meshes, and textures.

Layer 3+: Semantic Parts

Receptive Field: 11 Γ— 11+ px
Combines textures into wheels, dog ears, eyes, window frames, and entire object silhouettes.

The VGG Architecture Insight: Why Two 3Γ—3 Convs Beat One 5Γ—5 Conv

Simonyan & Zisserman (VGGNet) demonstrated that stacking two consecutive 3 Γ— 3 convolutionshas the identical effective receptive field as a single 5 Γ— 5 convolution, but with two massive advantages:

1. Fewer parameters: 2 Γ— (3 Γ— 3 Γ— C2) = 18C2 vs 1 Γ— (5 Γ— 5 Γ— C2) = 25C2 (28% parameter reduction).
2. More non-linearity: Stacking two layers includes two separate non-linear activations (e.g. ReLU) instead of one, giving the network greater representational capacity.

08

Build a Modular CNN in PyTorch

Architecting an image classifier using nn.Module, nn.Conv2d, and shape tracking.

Let us combine these concepts into a clean, modern PyTorch CNN class. Observe how the tensor dimensions transform after every single layer for a standard batch of (N, 3, 32, 32) input images:

Python 3.12 / PyTorch 2.6+
import torch
import torch.nn as nn

class SmallConvNet(nn.Module):
    def __init__(self, num_classes: int = 10):
        super().__init__()
        # Feature extraction backbone
        self.features = nn.Sequential(
            # Layer 1: Input (N, 3, 32, 32) -> Output (N, 16, 32, 32)
            nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, padding=1),
            nn.BatchNorm2d(16),
            nn.ReLU(inplace=True),
            # Pool 1: (N, 16, 32, 32) -> (N, 16, 16, 16)
            nn.MaxPool2d(kernel_size=2, stride=2),

            # Layer 2: (N, 16, 16, 16) -> (N, 32, 16, 16)
            nn.Conv2d(in_channels=16, out_channels=32, kernel_size=3, padding=1),
            nn.BatchNorm2d(32),
            nn.ReLU(inplace=True),
            # Pool 2: (N, 32, 16, 16) -> (N, 32, 8, 8)
            nn.MaxPool2d(kernel_size=2, stride=2)
        )

        # Adaptive pooling decouples classifier from input resolution
        self.gap = nn.AdaptiveAvgPool2d((4, 4)) # Guaranteed (N, 32, 4, 4)

        # Classification Head
        self.classifier = nn.Sequential(
            nn.Flatten(),                          # (N, 32 * 4 * 4) = (N, 512)
            nn.Linear(32 * 4 * 4, 64),
            nn.ReLU(inplace=True),
            nn.Dropout(p=0.3),
            nn.Linear(64, num_classes)             # (N, num_classes)
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x = self.features(x)
        x = self.gap(x)
        x = self.classifier(x)
        return x
Layer StageOperationOutput Tensor ShapeLearnable Parameters
InputRaw Image Batch(N, 3, 32, 32)0
Conv 1nn.Conv2d(3, 16, 3, padding=1)(N, 16, 32, 32)16 Γ— (3 Γ— 3 Γ— 3 + 1) = 448
Pool 1nn.MaxPool2d(2, 2)(N, 16, 16, 16)0
Conv 2nn.Conv2d(16, 32, 3, padding=1)(N, 32, 16, 16)32 Γ— (16 Γ— 3 Γ— 3 + 1) = 4,640
Pool 2nn.MaxPool2d(2, 2)(N, 32, 8, 8)0
Adaptive Poolnn.AdaptiveAvgPool2d((4, 4))(N, 32, 4, 4)0
Flattennn.Flatten()(N, 512)0
Dense 1nn.Linear(512, 64)(N, 64)512 Γ— 64 + 64 = 32,832
Dense 2 (Head)nn.Linear(64, 10)(N, 10)64 Γ— 10 + 10 = 650
09

Interactive CNN Training Simulator

Train a pattern-recognition CNN in real-time and observe convergence metrics.

Experiment with how channel capacity, learning rate, and training epochs affect model convergence. The simulator executes a numerical cross-entropy optimization on a multi-class image classification task with 3 geometric classes: Cross (+), Diagonal (X), and Ring (O).

Live CNN Training Playground

Epochs Run: 0
CROSS-ENTROPY LOSS:
1.098
TEST ACCURACY:
33.3%
MODEL PARAMETERS:
55
Training Loss History CurveInitial: 1.098 β†’ Current: 1.098
Select Sample Pattern to Inspect Network Prediction:
Cross (+)
Untrained
Diagonal (X)
Untrained
Box Ring (O)
Untrained
10

Feature Map Visualization & PyTorch Debugging Lab

Inspect live internal activation maps and resolve 8 real-world PyTorch CNN failure scenarios.

Feature Map Activation Inspector

A feature map represents the spatial responses of a single filter after convolution and activation. Select the active filter index below to observe how different kernels extract horizontal lines, vertical boundaries, or corner features:

Input 8Γ—8 Image
β†’ Conv2d + ReLU β†’
Feature Map #1 Activations

8 Realistic PyTorch Debugging Challenges

Diagnose and remediate 8 real-world errors frequently encountered when developing CNNs in PyTorch:

Case 1: Channel Dimension Mismatch in Conv2d

A 3-channel RGB image tensor is passed into a network whose first layer expects 1 channel.

Buggy PyTorch Code
import torch
import torch.nn as nn

# Input image batch: (Batch=16, Channels=3, H=64, W=64)
images = torch.randn(16, 3, 64, 64)

# Network designed for grayscale MNIST
conv = nn.Conv2d(in_channels=1, out_channels=32, kernel_size=3, padding=1)
out = conv(images)
RuntimeError: Given groups=1, weight of size [32, 1, 3, 3], expected input[16, 3, 64, 64] to have 1 channels, but got 3 channels instead
Select the Correct Diagnostic & Remediation:
11

Mini Project: Build an Image Classification Pipeline

A clean, runnable end-to-end PyTorch workflow from DataLoader to inference.

Here is a production-grade, self-contained Python script implementing the entire CNN workflow: loading batched image data, configuring modern normalization transforms, verifying tensor shapes, executing multi-epoch training with optimizer.zero_grad(set_to_none=True), and running inference with torch.inference_mode().

Python 3.12 / PyTorch 2.6+
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset

# 1. Data Preparation (Synthetic RGB 32x32 Dataset)
torch.manual_seed(42)
X_train = torch.randn(128, 3, 32, 32)
y_train = torch.randint(0, 10, (128,))

X_val = torch.randn(32, 3, 32, 32)
y_val = torch.randint(0, 10, (32,))

train_loader = DataLoader(TensorDataset(X_train, y_train), batch_size=16, shuffle=True)
val_loader = DataLoader(TensorDataset(X_val, y_val), batch_size=16, shuffle=False)

# 2. Modern CNN Architecture Definition
class VisionClassifier(nn.Module):
    def __init__(self, num_classes=10):
        super().__init__()
        self.backbone = nn.Sequential(
            nn.Conv2d(3, 16, kernel_size=3, padding=1),
            nn.BatchNorm2d(16),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(2, 2), # 32x32 -> 16x16

            nn.Conv2d(16, 32, kernel_size=3, padding=1),
            nn.BatchNorm2d(32),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(2, 2)  # 16x16 -> 8x8
        )
        self.gap = nn.AdaptiveAvgPool2d((1, 1)) # Guaranteed (N, 32, 1, 1)
        self.head = nn.Linear(32, num_classes)

    def forward(self, x):
        x = self.backbone(x)
        x = self.gap(x)
        x = torch.flatten(x, 1) # (N, 32)
        return self.head(x)

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = VisionClassifier(num_classes=10).to(device)
criterion = nn.CrossEntropyLoss()
optimizer = optim.AdamW(model.parameters(), lr=1e-3, weight_decay=1e-4)

# 3. Canonical Training Loop
for epoch in range(5):
    model.train()
    running_loss = 0.0
    for images, labels in train_loader:
        images, labels = images.to(device), labels.to(device)
        optimizer.zero_grad(set_to_none=True)
        outputs = model(images)
        loss = criterion(outputs, labels)
        loss.backward()
        optimizer.step()
        running_loss += loss.item() * images.size(0)

    epoch_loss = running_loss / len(train_loader.dataset)
    print(f"Epoch {epoch+1}/5 - Loss: {epoch_loss:.4f}")

# 4. Evaluation Loop with torch.inference_mode()
model.eval()
correct, total = 0, 0
with torch.inference_mode():
    for images, labels in val_loader:
        images, labels = images.to(device), labels.to(device)
        logits = model(images)
        preds = torch.argmax(logits, dim=1)
        correct += (preds == labels).sum().item()
        total += labels.size(0)

print(f"Validation Accuracy: {(correct / total) * 100:.1f}%")
12

Common Production Mistakes & Knowledge Assessment

Review core AI engineering pitfalls and validate your comprehension.

Top CNN Pitfalls to Avoid

  • Confusing HWC with CHW: Forgetting to transpose image arrays from NumPy/OpenCV before passing to PyTorch.
  • Hardcoding Linear Dimensions: Writing nn.Linear(512*4*4, ...) without adaptive pooling breaks on non-standard input sizes.
  • Overusing Large Kernels: Choosing 7Γ—7 or 11Γ—11 kernels in deep layers causes severe parameter bloat without added benefit.
  • Excessive Downsampling: Applying 5 consecutive pooling layers on a 32Γ—32 image shrinks spatial dimensions to 1Γ—1 prematurely.
  • Forgetting model.eval(): Evaluating models with BatchNorm and Dropout active leads to silent inference degradation.

AI Engineering Connections

  • Industrial Quality Control: High-speed defect detection on manufacturing assembly lines using custom CNN backbones.
  • Medical Imaging: Tumors and lesion segmentation on MRI scans, X-rays, and CT volumetric slices.
  • Autonomous Navigation: Real-time lane boundary detection and traffic sign classification.
  • Visual Search & Embeddings: Extracting dense feature vectors from penultimate layers for multi-modal vector database search.
  • Foundation Backbones: Modern architectures like ConvNeXt blend CNN efficiency with Transformer design philosophies.

What You Should Know Now Checklist

Understand why flattening images destroys 2D spatial grid topology and causes parameter explosions
Master the PyTorch standard (N, C, H, W) tensor layout and contrast with NumPy/OpenCV (H, W, C)
Can manually calculate a 2D convolution: elementwise product, sum, and bias addition
Differentiate a single 2D kernel slice from a multi-channel 3D filter (C_in, kH, kW)
Calculate output spatial dimensions using floor((H + 2P - D(K-1) - 1)/S + 1)
Calculate total Conv2d learnable parameters: C_out * (C_in * kH * kW + 1)
Explain the role of MaxPool2d vs AvgPool2d and understand receptive field growth
Architect a modular PyTorch CNN using nn.Module, nn.Conv2d, nn.ReLU, and nn.AdaptiveAvgPool2d
Debug shape mismatches, device collisions, and dimension ordering errors in PyTorch
Build an end-to-end training and evaluation loop with zero_grad(set_to_none=True) and torch.inference_mode()
Knowledge Assessment Quiz β€’ Question 1 of 8Answered: 0 / 8

Why does a standard fully connected (linear) layer perform poorly when applied directly to high-resolution raw image pixels?

Previous TopicPyTorch: Tensors, Autograd & nn.ModuleNext Topic Specialized Models: RNN & LSTM Basics