UPI Study › Courses › Introduction to Artificial Intelligence › Free lessons › Lesson 5.6 Free with a free account
Image-Focused Learning with Convolutional Networks
Introduction to Artificial Intelligence · Chapter 5: Neural Networks and Learning ArchitecturesSection 5.6 · lesson 37 of 6911 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Artificial Intelligence.
Lesson complete
Earn the 3 college credits for Introduction to Artificial Intelligence
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Sequence-Aware Learning with Recurrent Networks →← Training Networks: Backpropagation and Gradient MethodsNext lesson: Sequence-Aware Learning with Recurrent Networks →
In this lesson
How filters, stride, padding and pooling let networks read images.
- Compute a feature map value by sliding a filter over an image patch
- Calculate a convolution's output width from input size, filter size, padding and stride
- Compare max pooling with average pooling and explain what pooling achieves
- Describe how LeNet-5, AlexNet, VGG and ResNet shaped CNN design
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,517 words). Read along, or search it.
Opening Question
Finding Patterns Anywhere in a Photo
To a computer, a photo is just a grid of numbers. Yet a network can learn to spot an edge, an eye, or a wheel. And it can spot them wherever they happen to appear: top left, bottom right, anywhere. How? By scanning the image with small pattern detectors, the same detector at every position. That's a convolutional neural network, or CNN.
Image Basics
Pixels, Grids and Color Channels
A grayscale image is one grid, with one number per pixel. Larger numbers mean brighter pixels. A color image is three grids stacked together: red, green and blue. Each grid is called a channel. Even a small photo holds hundreds of thousands of numbers. Looking at all of them at once would be wasteful. A CNN looks at small patches instead.
Definition
Filters Slide to Make Feature Maps
The pattern detector is a filter, also called a kernel: a small grid of numbers, often three by three, or five by five. Convolution slides the filter across the image. At each position, multiply each filter number by the pixel beneath it, and add up the products. That single number goes into a new grid, the feature map. A large value means: the pattern this filter looks for is here.
Worked Example
A Vertical Edge Filter Scores 27
Here's a tiny five by five image. The two left columns are dark, zero, and the three right columns are bright, nine. So there's a vertical edge. The filter has minus one in its left column, zero in the middle, and plus one on the right. It responds when pixels get brighter from left to right. Lay it over the top-left window. Each row gives minus zero, plus zero, plus nine: nine. Three rows make 27. Slide one step right: the window still straddles the edge, so it's 27 again. One more step, over the uniform bright area, and minus 9 cancels plus 9: zero. So edges produce strong responses, and flat areas give zero. Different filters find different things. A horizontal-edge filter, with minus ones on top and plus ones on the bottom, gives zero everywhere on the image we just used, because every row is identical. And in a real CNN, nobody writes the filters by hand. The filter numbers are weights, and backpropagation learns them, so the network discovers which patterns are useful.
Quick Check
Horizontal Edge Filter Gives 18
Quick check, with a new window. Its top row is 2, 2, 2. The middle row is 5, 5, 5. And the bottom row is 8, 8, 8. Apply the horizontal-edge filter: minus ones on top, zeros in the middle, plus ones on the bottom. What value goes into the feature map? Pause, and work it out. Eighteen. The top row gives minus 6. The middle row is multiplied by zeros, so it adds nothing. The bottom row gives plus 24. Minus 6 plus 24 is 18: the image gets brighter going down, so this filter responds. Zero is what the vertical-edge filter would give here. And 24 forgets the top row.
Layer Parameters
Many Filters Stacked as Channels
A convolutional layer uses many filters at once. Each makes its own feature map, so a layer with K filters outputs K maps, stacked as channels. A filter also spans every channel of its input. On a color image, a three by three filter holds three times three times three, 27 weights, plus one bias. So a layer has K times, F times F times C, plus 1, parameters. 64 filters of three by three on a color image: 64 times 28, which is 1,792. After convolution, an activation such as ReLU is applied to every value, as in other networks.
Output Size
Stride and Padding Set Map Width
The stride is how many pixels the window moves each step. Stride 1 visits every position. Stride 2 skips every other one, so the map is about half as wide and tall. Padding adds a border of zeros around the image, so edge pixels are covered as often as central ones, and the output can keep the input's size. For input width N, filter width F, padding P and stride S, the output width is N plus 2 P minus F, over S, rounded down, plus 1. A five-wide image with a three-wide filter gives 3 at stride 1, and 2 at stride 2. Pad by 1, and stride 1 keeps all 5.
Pooling
Max and Average Pooling Shrink Maps
Pooling shrinks a feature map by summarizing small neighborhoods. Usually a two by two window slides with stride two, and keeps one number from each window. Max pooling keeps the largest. From this four by four map, the four windows give 6, 5, 9 and 8. Average pooling keeps the mean: 3.5, 2, 5.25 and 3.75. Pooling has no weights to learn. It leaves a quarter of the values, it tolerates small shifts, and each later value summarizes a wider part of the image.
Typical Architecture
Convolution, Pooling, Then Dense Layers
These pieces usually fit together one way. Convolution and pooling repeat, building up features, and fully connected layers at the end turn them into scores. Along the way, the feature maps get smaller, while the number of channels usually grows.
Quick Check
Width After Padding and Pooling
Quick check. An image is 32 pixels wide. It goes through a five-wide filter, with stride 1 and padding 2. Then two by two max pooling, with stride 2. How wide is it after each step? Pause, and work it out. 32, then 16. Padding 2 adds four columns: 32 plus 4, minus 5, over 1, plus 1, is 32. Pooling halves it, to 16. 28 is tempting, but it forgets the padding. That's exactly what padding 2 with a five-wide filter is for: keeping the size.
Landmark Networks
From LeNet-5 to ResNet
A few landmark networks show how these ideas grew. Several were judged on ImageNet: over a million labeled photos in a thousand categories, used in a yearly contest. LeNet-5, in 1998, set the recipe: alternate convolution and pooling, then fully connected layers. About 60 thousand parameters, reading handwritten digits. AlexNet, in 2012, won ImageNet by a wide margin, with about 60 million parameters, ReLU, dropout and graphics processors. It's widely seen as the start of the deep learning boom in vision. VGG, in 2014, stacked only small three by three filters, 16 or 19 weight layers deep. And ResNet, in 2015, added skip connections, and trained networks up to 152 layers.
Design Choice
Why VGG Stacks Small Filters
Why small filters? Two three by three layers in a row let each output see a five by five patch. Three of them see seven by seven. With 64 channels in and out, one five by five layer needs 102,400 weights. Two three by threes need only 73,728. One seven by seven layer needs 200,704. Three three by threes need 110,592. Fewer weights, the same view, and extra ReLU steps in between.
Residual Learning
Skip Connections Pass Inputs Through
As networks grew deeper, researchers hit a surprise: beyond some depth, adding layers made the training error worse, not better. ResNet's fix is the residual block. It computes a correction, F of x, and adds it to its own input. The output is F of x, plus x. If a block has nothing useful to add, it learns F of x near zero, and passes its input straight through. The skip path also gives gradients a direct way back. ResNets up to 152 layers won the 2015 ImageNet contest, with a top-five error of about 3.6 percent.
Key Ideas
Four Reasons Convolution Suits Images
Why does convolution suit images so well? Four reasons. Local connections: each output looks only at a small patch, because nearby pixels are related. Weight sharing: one filter is reused at every position, so a pattern is recognized wherever it appears, with far fewer weights. Shift-friendly maps: move an object in the image, and its feature map moves by the same amount. And a hierarchy of features: early layers respond to edges and colors, middle layers to textures and parts, and deep layers to whole objects.
Parameter Count
Dramatic Savings in Weights
The saving in weights is dramatic. On a 28 by 28 grayscale image, a fully connected layer of 100 neurons needs 78,500 parameters. Six five by five filters need 156. On a 224 by 224 color image, 1,000 dense neurons need about 150.5 million. 64 three by three filters need 1,792. The two layers produce different outputs, so this shows how cost scales, not a one-for-one swap. Fewer weights mean less memory, faster training, and less overfitting.
Limitations
Rotation, Scale and Position Matter
Two limits. Convolution handles shifts, but not rotation or size changes by itself. Networks usually learn those from training images that include them. And sometimes position matters. If a feature means something only in one region, sharing a filter everywhere ignores that, and later layers must supply it.
Key Takeaways
Filters, Pooling and Landmark Designs
To sum up. A filter slides across an image, multiplying and adding, to make a feature map that marks where a pattern appears. Stride and padding set the output size, and pooling shrinks maps by keeping one value per window. LeNet set the recipe, AlexNet proved it at scale, VGG stacked small filters, and ResNet added skip connections. Local connections, weight sharing and a hierarchy of features cut parameters enormously.
Think About It
When Sharing a Filter Fails
Something to think about. An eye can appear almost anywhere in a photo of a face. Why does sharing one filter across all positions make sense for finding eyes? And describe a task where sharing a filter everywhere could be a poor choice, because the position of a feature matters.
About Introduction to Artificial Intelligence at UPI Study
Introduction to Artificial Intelligence (Computer Science 373) is a self-paced online course of 69 video lessons in 9 chapters, from intelligent agents and search to game strategy, neural networks, logic and reasoning, machine learning, language, robotics and AI ethics. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: AI vs Current Trends in CS and IT
Why take it here
Why students take Introduction to Artificial Intelligence with UPI Study
Where the credit goes
Universities that work with NCCRS
Introduction to Artificial Intelligence carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Image-Focused Learning with Convolutional Networks
What is a convolutional neural network?
How do you calculate the output size of a convolutional layer?
What is the difference between max pooling and average pooling?
Why do CNNs need fewer parameters than fully connected networks?
About the Introduction to Artificial Intelligence course
How many college credits is Introduction to Artificial Intelligence?
How much does Introduction to Artificial Intelligence cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Artificial Intelligence take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Introduction to Artificial Intelligence.
69 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →