Computer Science
Grade 12
20 min
Convolutional Neural Networks (CNNs): Image Recognition
Learn about CNNs, their convolutional layers, pooling layers, and their application in image recognition tasks, including image classification and object detection.
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Explain the function of the core layers in a CNN: Convolutional, Pooling, and Fully Connected.
Trace the flow of data (an image) through a simple CNN architecture, describing how its representation changes at each layer.
Manually calculate the output of a convolutional layer given an input matrix, a filter (kernel), and a stride.
Manually calculate the output of a max pooling layer given an input feature map.
Identify key hyperparameters of a CNN, such as filter size, stride, and padding, and explain their impact on the output dimensions.
Differentiate between feature extraction (convolution/pooling) and classification (fully connected) stages within a CNN.
How does your phone instantly recognize your face to unlock, or how can a social media app suggest...
2
Key Concepts & Vocabulary
TermDefinitionExample
Convolutional LayerThe primary building block of a CNN. It uses a set of learnable filters (kernels) that slide across the input image to detect specific features like edges, corners, or textures, creating feature maps.A 3x3 filter designed to detect vertical edges might have values [[1, 0, -1], [1, 0, -1], [1, 0, -1]]. When this filter slides over a part of an image with a vertical line, it produces a high activation value in the corresponding feature map.
Filter (or Kernel)A small matrix of weights that is convolved with the input data. Each filter is specialized to detect a particular feature.In a 2D image, a filter is a small grid (e.g., 3x3 or 5x5 pixels) that the network learns to recognize patterns like a horizontal edge or a specific color.
Feature Map (or Ac...
3
Core Syntax & Patterns
Convolution Operation
Output = Sum(Element-wise product of Filter and Input Patch)
This is the core mathematical operation of a convolutional layer. The filter slides across the input image (or feature map) one patch at a time (the size of the patch is the size of the filter). At each position, you perform an element-wise multiplication between the filter and the image patch and sum the results to get a single value in the output feature map.
Output Dimension Formula (Convolution)
Output_size = ( (Input_size - Filter_size + 2 * Padding) / Stride ) + 1
Use this formula to calculate the width or height of the feature map produced by a convolutional layer. 'Input_size' is the height/width of the input, 'Filter_size' is the height/width of the filter, 'P...
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
An input image is 28x28. It passes through a convolutional layer with a 5x5 filter, stride 1, and padding 2. Then, the output passes through a max pooling layer with a 2x2 filter and stride 2. What is the final output dimension?
A.14x14
B.13x13
C.28x28
D.12x12
Challenging
A student builds a deep CNN but omits the ReLU activation function after each convolutional layer. The network fails to learn complex features for image recognition. Why is this the expected outcome?
A.Without ReLU, the feature maps become too large to process.
B.Without ReLU, the model cannot perform backpropagation to update its weights.
C.Without ReLU, the pooling layers will average to zero.
D.Without ReLU, the entire network of stacked linear operations collapses into a single, less powerful linear function.
Challenging
You are designing a CNN for analyzing high-resolution medical scans where tiny, subtle details are critically important for diagnosis. How might you adjust your use of pooling layers compared to a CNN for classifying small, centered icons?
A.Use very large pooling windows (e.g., 8x8) to quickly reduce dimensions.
B.Use smaller pooling windows (e.g., 2x2) with a stride of 1, or replace pooling with strided convolutions to reduce information loss.
C.Use pooling layers at the very beginning of the network to remove noise.
D.Use average pooling instead of max pooling exclusively.
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing FreeMore from Artificial Intelligence: Deep Learning Fundamentals and Applications
Introduction to Neural Networks: Perceptrons and Activation Functions
Multi-Layer Perceptrons (MLPs): Architecture and Backpropagation
Recurrent Neural Networks (RNNs): Sequence Modeling
Long Short-Term Memory (LSTM) Networks: Overcoming Vanishing Gradients
Word Embeddings: Representing Words as Vectors (Word2Vec, GloVe)