Convolution Operation in CNN

Learn With Jay · Beginner ·🧬 Deep Learning ·4y ago

About this lesson

In this video, we will understand what is Convolution Operation in CNN. Convolution Operation is the heart of Convolutional Neural Network. It is responsible for detecting the edges or features of the image. The main reason for the good performance of Convolutional Neural Network is Convolution Operation. With simple mathematics, you will understand how Convolution Operation in CNN is able to detect edges of the image. Then we will also discuss how the Convolution Operation is performed in a colored image. This video will be a complete package to understand Convolution Operation in CNN. ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Timestamp: 0:00 Intro 1:26 Convolution Operation in CNN 4:07 Vertical Edge detection 6:21 Convolutional Layer 7:23 Convolution Operation for Colored Image 9:12 End ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ 📕 Assessment quiz - https://forms.gle/1B2yYCPJSrgbv2nY8 ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Follow my entire playlist on Convolutional Neural Network (CNN): 📕 CNN Playlist: https://www.youtube.com/watch?v=E5Z7FQp7AQQ&list=PLuhqtP7jdD8CD6rOWy20INGM44kULvrHu At the end of some videos, you will also find quizzes that can help you to understand the concept and retain your learning. ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ ✔ Complete Neural Network Playlist:https://www.youtube.com/watch?v=mlk0rddP3L4&list=PLuhqtP7jdD8CftMk831qdE8BlIteSaNzD&t=0s ✔ Complete Logistic Regression Playlist: https://www.youtube.com/watch?v=U1omz0B9FTw&list=PLuhqtP7jdD8Chy7QIo5U0zzKP8-emLdny&t=0s ✔ Complete Linear Regression Playlist: https://www.youtube.com/watch?v=nwD5U2WxTdk&list=PLuhqtP7jdD8AFocJuxC6_Zz0HepAWL9cF&t=0s ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ If you want to ride on the Lane of Machine Learning, then Subscribe ▶ to my channel here: https://www.youtube.com/channel/UCJFA

Full Transcript

convolution operation is the heart of cnn it is responsible for detecting the edges and the features of the images the main reason for the good performance of the convolution neural network is convolution operation so what is special about it is it a very complicated operation that is hard to understand or is it just a simple mathematics that is giving great result we will find out that in this video also at the end of the video you will be able to take the quiz to check your understanding on convolution operation this quiz will have multiple questions and after you submit the quiz you will be able to see your score as well as the proper explanation about every single answer i remember when i was starting to learn these concepts quizzes like these were responsible for improving my understanding of the concept and retain what i learned so make sure to give the quiz and you can attend the quiz as many times as you want and if you are new to this channel consider subscribing because i upload new machine learning videos every single week where i provide mathematical detailed concepts about machine learning models and afterwards we implement it in python so if you want to ride on the lane of machine learning then hit the red subscribe button also hit the bell icon and let's not wait further and let's get riding let us say we have this small image of size 6 cross 6 pixel and these values or these numbers represent the pixel value of the image normally if the image is a grayscale or black and white image then every pixel value ranges from the scale 0 to 255. 0 represents the black end of the spectrum while 255 represent the white end of the spectrum but for simplicity let us consider this is a simple image with these values and we also have this filter of size 3 cross 3 pixel and the convolution operation between this image and this filter will generate a 4 cross 4 resultant matrix and the values of these this matrix can be obtained by superimposing this filter on this image and using this as a sliding window now what we will do is that we will multiply the values in each cell and then add all the values together means one will be multiplied with one two will be multiplied with one and so forth with four with the minus one and then all these values will be added together to create this output number and this output number will be placed at this position now afterwards we will slide this window by one pixel to the right again multiply the individual values and add them up together to generate the output number and this output number will be placed here and similarly we will repeat the process by sliding this window again by one pixel to the right and then calculating the value and placing it at this position and once we reach at the end of the image we will move the filter by one pixel down and we will start the process all over again this way we will fill the entire resultant matrix until we reach at the end of this image so this final minus 3 is generated by multiplying these numbers together and adding all the values so this entire operation of getting this resultant matrix from this picture and the filter is called convolution operation and it is denoted by this star symbol you will notice one thing here is that we used an image of size 6 cross 6 pixel and filter of size 3 cross 3 and the resultant matrix is of size 4 cross 4 so any image of size n cross n when convolved with the filter of size f cross f will generate the output of n minus f plus 1 cross n minus f plus 1. now you might be wondering what is so valuable about this convolution operation and why do we even use this in our cnn what i can tell you is that this convolution operation is responsible for identifying the edges and the features from the images let us see how let's say we have this simple image where this one represents the white color and 0 represents the black color now you can see that there is a presence of an edge in this image now we can convert this image with this filter and this filter acts as a vertical edge detector let's see how it is able to detect this vertical edge by performing the convolution operation of this picture and this filter we will get this first value as 0 then we will shift this filter by 1 pixel to the right then this value will be 3 then again we will shift this filter then again we will get this value as 3 then after shifting it again we will get this 0 again so the convolution of this picture with this filter will be this matrix now this matrix can again be treated as an image after proper rescaling 0 will be considered as a black and or the darker side of the spectrum and the three will be considered as the brightest side of the spectrum so the final image will be this and you can see that this there is an edge at the center which is able to identify the edge here in this image a practical application of this can be found out by convolving this real world image with this exact filter and when we do that the resultant output will be this image you can see that it is able to identify or highlight all the vertical edges very much thus a convolution operation acts as a feature detector or the edge detector in our cnn now similarly if we were to detect the horizontal edges then what we can do is that we can take this another filter which is just the transverse of this filter and this filter will act as a horizontal edge detector and when we convert this filter with this image with the same image we get this resultant image and you can see in this image that the horizontal edges are highlighted so that is how the convolution operation acts as a feature detector in convolutional neural network and that's why it is the heart of our cnn now in a single layer of a convolutional neural network we will be using many number of such filters different filters will be detecting different features of these images for example one filter might detect the horizontal edge while one filter might detect the vertical edge while one filter might detect the circles or circular feature in our images and if we use let's say c number of such filters in one layer then the resultant output will have c number of images as you saw previously that by convolving a single image with two different filters we got two different images in our output so that's why by convolving a single image with c number of filters we will get c number of images in our output so a convolving a grayscale or a black and white image of size n cross n with a filter of size f cross f and total c number of filters will give the output of size n minus f plus 1 cross n minus f plus 1 cross c okay so here we had a grayscale image and that's why we had only one channel but what if we have a colored image like this then a colored image will have three channels which will be red green and blue channels and thus the size of one colored image will be n cross n cross three then how will we perform the convolutional operation in a colored image for performing a convolution operation on a colored image we will need a filter which also have three channels so the size of this filter will be f cross f cross three now the number three and three here should match this filter has total number of 27 values considering all these values and you can consider this filter as a 3 dimensional cube and to find the convolution operation between this image and this filter we will superimpose this filter onto this image and we will multiply all the values in the individual cell now all these 27 values will be multiplied in every cell and all these 27 values will be summed up to generate a one resultant output and that output will be placed at this position and again we will shift our filter by one pixel to the right and we will be able to find the value at this position and we will continue this process till we reach at the end of the image thus a single image of size n cross n cross 3 con when convert with the filter f cross f cross size three generates only a single image of this size now again we will use many such filters in a single layer of our convolutional neural network let's say if we use three filters then in the output we will get three different images so this was our entire convolution operation now you might be wondering here that in the previously seen example we took a filter in which we hard coded a value as one one one zero zero zero and minus one minus one minus one and this filter acted as a vertical edge detector so will we be hard coding these values of every filter no that will be actually very stupid so what values should these filter actually take to find the answer to this question continue watching my videos on this convolutional neural network series where i will be answering everything about convolutional neural network in detail i will give you a small trailer here that what we will do is that we will actually treat these values in our filter as parameters to train now after training this convolutional neural network or after training our model these parameter value will take certain value by themselves which will be able to detect the associated features from the images and we will find out how does these things happen in this series and before you go any further make sure you give the quiz the quiz is just one click away and you will find that quiz down in the description box this quiz will highly help you to improve your understanding on with this convolution operation and retain whatever you have learned so make sure you give this quiz and do let me know in the comments below how did you find this video and if you found this video helpful then do give this video a thumbs up and after you submit the quiz come back to this video again to watch the next video the link to the next video you will find in the description box so i will see you in the next video

Original Description

In this video, we will understand what is Convolution Operation in CNN. Convolution Operation is the heart of Convolutional Neural Network. It is responsible for detecting the edges or features of the image. The main reason for the good performance of Convolutional Neural Network is Convolution Operation. With simple mathematics, you will understand how Convolution Operation in CNN is able to detect edges of the image. Then we will also discuss how the Convolution Operation is performed in a colored image. This video will be a complete package to understand Convolution Operation in CNN. ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Timestamp: 0:00 Intro 1:26 Convolution Operation in CNN 4:07 Vertical Edge detection 6:21 Convolutional Layer 7:23 Convolution Operation for Colored Image 9:12 End ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ 📕 Assessment quiz - https://forms.gle/1B2yYCPJSrgbv2nY8 ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Follow my entire playlist on Convolutional Neural Network (CNN): 📕 CNN Playlist: https://www.youtube.com/watch?v=E5Z7FQp7AQQ&list=PLuhqtP7jdD8CD6rOWy20INGM44kULvrHu At the end of some videos, you will also find quizzes that can help you to understand the concept and retain your learning. ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ ✔ Complete Neural Network Playlist:https://www.youtube.com/watch?v=mlk0rddP3L4&list=PLuhqtP7jdD8CftMk831qdE8BlIteSaNzD&t=0s ✔ Complete Logistic Regression Playlist: https://www.youtube.com/watch?v=U1omz0B9FTw&list=PLuhqtP7jdD8Chy7QIo5U0zzKP8-emLdny&t=0s ✔ Complete Linear Regression Playlist: https://www.youtube.com/watch?v=nwD5U2WxTdk&list=PLuhqtP7jdD8AFocJuxC6_Zz0HepAWL9cF&t=0s ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ If you want to ride on the Lane of Machine Learning, then Subscribe ▶ to my channel here: https://www.youtube.com/channel/UCJFA
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
Understanding Deep Learning Through Four Interactive Experiments
Explore deep learning concepts through interactive experiments to gain hands-on understanding
Medium · Data Science
📰
Understanding Deep Learning Through Four Interactive Experiments
Explore deep learning through interactive experiments to gain hands-on understanding
Medium · Deep Learning
📰
Optimizers in Deep Learning: From Gradient Descent to Adam
Learn how optimizers in deep learning work, from basic Gradient Descent to advanced Adam optimizer, to improve model training
Medium · Deep Learning
📰
The Meta-Architecture of Interface Fracture: High-Dimensional Logical Stress and Systemic Collapse…
Learn about the meta-architecture of interface fracture and its relation to high-dimensional logical stress and systemic collapse in deep learning systems
Medium · Deep Learning

Chapters (6)

Intro
1:26 Convolution Operation in CNN
4:07 Vertical Edge detection
6:21 Convolutional Layer
7:23 Convolution Operation for Colored Image
9:12 End
Up next
Image Classification with ml5.js
The Coding Train
Watch →