Good evening, everybody. Am I audible? Good evening. Good evening. Thank you. Thank you. So we are starting our class. In the previous session, we have completed the natural language processing, what it is, what are the text vectorization, various methods of the text vectorization was the topic in the last class. Today, we will start one of the most famous deep learning model, the CNN. the full form of the cnn is convolutional neural network network and it is a one of the most fundamental modern days architecture why i call it the fundamental because many many modern models like, if I can say, you might have listened to this name like ImageNet, very famous model, ImageNet, ResNet, ResNet, MobileNet, and many many many many many more. all are nothing but simply a variant of the CNN so we don't need to go in the detailed discussion of all individual modern day architecture because almost the fundamental is common and the common part is what CNN so that's why I will cover the CNN in the detail it is in your syllabus later depend on your choice and interest you can refer the others model they are nothing but simply a variant of the CNN. Okay, so I will start with a discussion on ANN versus CNN. ANN versus CNN. Conceptually CNN is also a type of ANN, so don't get confused. ANN is what? Artificial neural network or any neural network. So CNN is not something that is a totally different from the ANN. So the discussion is here ENN versus CNN in this context like we have seen very common model like a perceptron, we have seen withdrawal of learning rule of learning rule and similar more. So what was the problem with such network in conventional network and how those problems we have solved with the CNN. That transition we want to understand and in this understanding discussion you will feel the benefit and internal architecture of the CNN. So let me have one example. I will explain the things in the example. So like we are going to start the conventional neural network versus CNN. So suppose we have this famous data set, MNIST data set that is for hand-written digit recognition. So data set contains thousands of images of a human-written digit 0 to 9 and suppose our objective is to train a neural network model that can identify, that can detect or classify the human written digit what it is. Suppose human has written zero, so your models would understand it is 0, 1, 2, 3 or 1. Okay, suppose this is the background. This is about the Amnesty dataset. Everybody must know it. Contains 60,000 training samples, where 10,000 are test samples. The size of each image is 28 x 28 and it is a grayscale images. so the range of pixel varies from 0 to 255. So there is a one question maybe like what is the difference between black and white image versus gray scale images? Gray scale images. So difference is where in the pixel, this pixel either will contain value 0 or 1 okay but in the gray scale images it contains range pixel maybe than 0 to 255. That is one difference between gray scale image and black and white. So this data set contains the gray scale images. So this is some sample from the data set. The images are like background is in black color and digits are represented into the white color. So very simple images. The images in real sense are not totally either black and white, it range from 0 to 55. So how the computer see the images? Just for simplicity, you consider left hand side it is one image. Images are represented in the form of matrix. Each matrix, each value contains some pixels. For example, in this data set, as we have seen the image of digit of size 28 x 28, what is the meaning of that? Each image will be represented with the matrix, with the matrix like that, where number of column will be 28, number of row will be 28. So this matrix of 28 x 28, each cell contains some value, each cell contains some value okay. So these values range will be 0 to 55 to 55. Just for simplicity in either way you can consider typical 0 means either you can consider is a white or vice versa black, okay. One means or 255 because range is here 255, either you can consider is a black or white, okay. Depends on the representation of the computer. So look here, this is the image that a human just see it. Middle one is a one representation that you can understand the range of pixels. You see the background, suppose it is a black color at the corner, you see the pixel range is 0 or close to 0. So how it is presented to the computer? The range from 0 to 255. 0 means the black color and white color represent with the 255 or close to 255. So you can easily understand in the middle one pattern is making where the white colors are following the shape of the 8 and the right hand side is a clear representation the way computers see the images. Okay, so if you can observe where are the white portions are shaped in the image, the pixel values are higher side and the background that is a black color, pixel values are lower side. So that is the way computers see the images. So let me have a one exercise with you, for example, consider for a simple case we have an image and image size is 5 x 5 or you want a neural network, a simple neural network like consider for a simplicity perceptron. So in the perceptron we require the input layer. So can you tell me how many neurons we need to consider in the input layer? Anyone? Then you may have a multiple hidden layers it's up to you like like like then output layer okay length output layer just my question is here how many neurons we need to keep into the input layer somebody's uh 30 okay it is 25 because how many pixel values are there how many cells are there 25. So you will have a 25 neuron plus one extra bias. So 25 neurons will be the input layer. A hidden layer is up to you. There is no such links you can define. Very good, good answer. Okay, so now just consider, you just check your mobile, the normal size of image. It is much more than it is written here suppose your image in the form of color image okay in the real life example suppose in the surveillance camera or any other other application you are thinking where the image will be going to the model model has to detect the object or model has to classify the image so normal images are in color images so color images have a channels so so this is the size of matrix. In common, very common size of image is 1920 x 1080 and 3 means what here? This is channel. Channel means suppose RGB. So it is a color image so there will be three channels. So there will be such three matrices. So it is very very very very common size of image. Now you tell me suppose this image you want to process, how many neurons you will need to keep in the input layer. Very simple question. This is a small image you want to send to the computer for a to the you want to give the neural network model. What will be the size of input layer? You tell me. Number is given here. Are you getting my question? I have written some number around 6 million. Okay, so 6 million neurons are required and consider we have only single hidden layer with the four neurons. So it is impractical setup. Why I am saying it is impractical? Normally if you have an input layer, if you have an input layer that have a six million neuron immediately to the hidden layer, it is impractical to have only four neurons. Because this much of a drastic change from six million to four is normally impractical. But consider a very even and impactful scenario. Suppose you have four neurons in the next hidden layer, so how many connections will be required? How many weights will be required between input layer and the next hidden layer? Six millions multiply for 24 millions weights you need to keep between the input layer and the false hidden layer. And you may have many such hidden layers. So in the simplest scenario, the total number of parameters and weights will cross billions. It is a big issue. So you need to update the weight. You recall the forward propagation, the back propagation. You have to process billions of the weights in every time. You need to update the billions of the weight in every epoch, in every back propagation. So normal machine cannot handle it. So it is a very challenging for a neural network to handle the images. Is it clear? Very simple. If you have 6 million neurons in the hidden layer, next 6 million neurons in the input layer, next layer you have only the 4 neurons. how many weights will be there? 24 millions. And similar many hidden layers will be there. So billions of weights you need to manage to process the simple image in the typical ANN setup. Things are clear? Is it clear to everybody? Okay. Another problem with the common ANN, like suppose even you are successful to train the model, so it is fixed with the location. So suppose two is a one object or it may be cow, it may be cat, it may be a digit. So if you feed the nest image for a model, if location of the object change in the image, your ANN starts to fail. So it is sensitive against the location of the object. I want a model that can detect the object wherever it is in the image, but ANN cannot do it. So these are the two huge problems we have seen. That is a really huge problem with the ANN. So particular ANN start creating the problem when we deal with the images, we deal with the videos. These things you need to understand and in the ANN, it is sensitive against the location, against the location of the object. It is the biggest problem because you cannot guarantee object always be, if you are sending the image of the cat, cat always be here, you cannot guarantee it. In the next image it can be here, it can be here, it can be here, it can be in any place in the image. So you are ANN failing. So these are the two big reasons people started thinking to develop the new model and the solution is the CNN. Solution is the CNN. So in the CNN there are a lot of new terminologies and keywords you need to understand like image. Just I have discussed convolution operation, what is kernel, filter, feature detector, feature maps, stride, padding, pooling, sort maps and many many such things are there. So one by one I will introduce every term in the view of CNN. So before jumping to the detail if you just search in the google what is CNN or architecture of the CNN you will find such kind of images. Some of the very prominent and very common architectural images from the google have taken to make you familiar with this model. So just just start observing the new keywords where it are in the architecture. Input is given as a car. So first operation you can see at the bottom convolution operation happens something. What is it is I will discuss. There are some feature maps concept. There may be many feature maps. There is some pooling operation. So what it is doing? It is reducing the size of feature map. It clearly visible in this image. Once such operations are over, it gives us a list of features. So that's why this block we call it feature extractions. So ultimate CNN is designed for automatic feature extraction. We understand the word. CNN, we don't need to give the feature to the CNN. CNN itself creates their own feature. So, again, you will understand later, again, the third biggest difference between CNN and the ANN. Here, we need to give the manual feature. If data set have a feature, it will work like age, like a salary, like a gender and many more other way. So, data set must have the feature. Then, ANN will work. CNN is automatic. It is not a human and your responsibility. Automatic extract the feature. That is the most powerful feature of the CNN. How it will extract, I will discuss today. So once we have a feature, those features you can give for any of the classifier for classification purpose. It again a similar image, you just give the input of image 32 x 32 it will go to the convolution operation there we have a lot of feature maps then then then it will go to a lot of convolution operations then final features then for classification again one simple arrangement of the component in the cnn is what first the image is given to the cnn it will go with the convolution operation with some activation function Then the pooling layer, then the dense layer, the flattening layer, then the classification layer. Similarly, I am just adding more architecture from the internet so that you become familiar about the terms. Every time directly the image will be given to the convolution operation, then the pooling, then again the convolution, then again the pooling. So you need to understand with this diagram, there may happen multiple time convolution operation, pooling operation, convolution operation, pooling operation, multiple time. Once this is over, you can arrange all the features that are extracted by this process in the form of fully connected layer. That can be used for a classification. More clear picture is here. Now ReLU, if you remember, we have covered the ReLU activation function. So what happened, given the input image, first convolution operation with ReLU, then pooling, then again convolution operation with ReLU, then pooling, such blocks can have multiple time in the CNN. It's up to you. You may be worried about how you are going to design, it's up to you. Like a simple ANN, nobody is going to tell you how many hidden layers will be there, number of neurons in the hidden layer. Just hit and try and based on the experience, you can think about how many convolutional operations, how many pooling operations are required. So what is the convolution? If you have any computer vision experience and you have done like how to blur the image, to smooth the image, how to detect the edges from the images, how to sharpen the images, these all are the convolutional operation. So convolution is nothing but a simply multiplication of the two matrix. Okay, let me explain with the detail. So in the context of the deep learning, convolution is an element-wise multiplication of the two matrix followed by a sum. Understand this line, very important line. Convolution with respect to the CNN is element wise multiplication of the two matrices followed by a sum. Okay, mathematically I will explain that part. So just need to think whether if you want to multiply the two matrix, what should be the size of those two matrix, just think about it. It is an LMI element wise multiplication is not a dot product. Now at the below one paragraph is written. It is very important. I'm going to elaborate the first paragraph here. Convolution is an operation multiplication plus move. At the first line it is written element wise multiplication. I am going in more detail not it is not only element wise multiplication, it is element wise multiplication plus move. What do you mean by move? I will get it. We apply the two concept tiny matrix and big matrix and we have to scan the given input from left to right and top to bottom. Please remember these two words. Moving means what? Here moving means means you have to scan the image from left to right and top to bottom and there is a concept of tiny matrix and big matrix. Okay, what it is? So big matrix means what? Your image. It is written. Whatever the image is given to you, the images are represented with the form of matrix, column and rows. that image we call it as a big matrix. Then you have to define your own matrix, tiny matrix. We call it kernel. Please, these are a very confusing word. Please understand today. Either we call it kernel, filter, feature detector, convolutional matrix, all are the same words. What is this? This is a small matrix, user-defining small matrix. Okay, so understand there will be two images in the CNN. This is your input image. Okay, I'm calling it as a big matrix. It comes from the data set. Okay, input image. Then we have a small image. We call it kernel and other name. Here for simplicity given the name a tiny matrix. What we have to do? We have to keep this image and start scanning from left to right. Then do some element wise multiplication like that, like that, then top to bottom, then top to bottom, then top to bottom, then top to bottom. So whenever you start picking this tiny matrix scanning from left to right of the input image and top to bottom, in every time what you are doing, image a matrix multiplication, matrix multiplication, matrix multiplication, matrix multiplication. So this process, multiplication plus move, understand this is called convolution operation. Is it clear to everybody? Understand one by one, what is the convolution operation? So just understand there will be two images. It is a user defined, user defined. So, user defined means what? User defined means like a kernel. Suppose I am going to define the matrix 2 x 2, very small matrix. There will be a 2 column, consider 3 x 3. Agree? So, what will be the value? Ultimate, these are the weights. These are the weights. Practically, these are the weights. Very important part I am discussing. So, these are the weights. How to initialize the weight? Randomly. Agree? This is called kernel or time matrix. You need to take this matrix and input image you have to put on the input image do multiplication then move then multiplication then move then multiplication then top to bottom move multiplication move multiplication move multiplication agree this is called convolution up to this moment if you have any question here in this context only then please ask the user defined not fixed dimension it is user defined normally it is 2 cross 2 or 3 cross 3 okay there's no fixed rule to define it so it's up to you you can define the tiny matrix 2 cross 2 or 3 cross 3 normally people keep it 2 cross 2 okay great so here okay so yeah why we call it feature detector very interesting discussion so here the name like matrix name is kernel it's also one name is filter Both are same. It's also name is another name is feature detector. What is a feature in image? Any idea? What are the features in the images? That you need to understand. Very interesting part. Feature means what? In an image, edges may be a feature. Vertical line are the feature. Horizontal line are the feature. Bands, curved line, diagonal lines, loopy circle, color, intensity, and high level features are like eyes, nose, lips, cheek, teeth, and many, many, many more. All are the features. Great, great. So, I think everybody agree with this concept. Any image will be given. there will be many features I think agree there will be many features many and I already explained we have to extract the feature means we have to detect the feature there is no manual features so there is and and CNN has to do it so how to CNN detect those feature by using the kernels So, there will be many kernels, kernel 1, kernel 2, similarly n number of kernels. It just for understanding, this kernel may detect the intensity, it may happen. This kernel may detect the edges, this kernel may detect the circle pattern like that. Got it? In high level, understanding is clear to everybody. so these are the kernel like you have to find the convolutional operation there will be many such kernels so just revisit this look feature map the kernels there are many there are many kernels ok so we understood the kernel now everybody stop asking the question just see here what I am going to explain. Okay? How it works kernel is a function. I don't know Caussic. I don't know that because kernel already I have discussed it is a matrix according to it may be a function I don't know. So how it works please focus on the screen. Suppose this is the input image 9. Okay? 9 is the image given to the model. and 9 image is represented with the form of matrix. So see consider a very small matrix like 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 7 cross 5. So you are representing this 9 as a matrix. If it is a grayscale matrix, the range will be 0 to 255. But we are not here to discuss that detailed version. Our focus is to understand the scanning process working of the CNN. So we kept number like if it is a background means white color it is minus 1 and where are the black color it will be 1. Okay and actually in the back back color that is a white it will be represented with the 0 or close to the 0 value and the black color intensity will be given to the around 255 or any value close to the 255. It is clear? Just refer this example and actually these such kind of images will be given. Background will be smaller number and other drastically change pattern in the higher values will be represented. Okay, actually this type of images will be given to the CNN bot. For a simplicity, which matrix size I am not getting. I have discussed two kinds of matrix. Which matrix size you are talking about? So if data set is given to you in the form of image you don't have choice to decide the size of image from the data set. Okay, kernel size I already discussed. It is normally we keep it 2 x 2. Okay, Mohit, I already cover it. Okay, kernel size is normally 2 x 2 or 3 x 2. It is a small number, a small matrix. Okay, Mohit, is it clear? So, consider this case. So, yeah. So, as a human, you can visualize this 9 is represented with this matrix. wherever the pattern of dark color will go around the matrix, the pixel value will be higher side and the remaining places pixel value will be lower side. This is the way computer see the images. Now assume that this is the filter. Why I'm assuming? Because ultimate, during the training you will get such kind of filter but initially you need to define a matrix like a 3 x 3. So this is a user defined matrix 3 x 3. It is a tiny matrix, it is a kernel. So assume that this is the kernel and this kernel is able to detect the loopy pattern. Agree? Like I have already discussed, since we have a lot of features in the images, each feature will be detected by the individual kernels. For this kernel maybe for the edges, another kernel maybe for the loopy circle, another kernel maybe for another pattern. So this is a kernel. Assume that this kernel is able to detect the loopy pattern. If in the images wherever the loopy pattern is there, the kernel will detect it. So why it is a loopy pattern? Because at the border size it is 1 1 1 1 means it is a higher intensity pixel and at the center it is minus 1. So in the same way you can see this is the 9. Wherever the 9 is moving, edges are moving, pixel having the higher value and other places pixel having the lower value. Similarly, if a loopy pattern means circular pattern, wherever the circular pattern are in the image, the pixel value will be higher side, else the pixel value will be lower side. Loopy pattern is clear. This is the filter 3 x 3. So now we have two images. This is the one image that is input image and this is the kernel you have defined it. Assume that your kernel is able to detect the loopy pattern. Got it up to this moment? Okay, so now let me discuss on how this operation happened. So as we know in the convolutional operation is what? You need to pick you need to pick this image and you have to scan from left to right and top to bottom from the input image. Okay, Anujay, yes, wait for that one. Filter will not decide, it will come through the training. So, understand what I am explaining. So, convolution is, operation is what? As we discussed, you need to multiply the two matrix, the tiny matrix you have to put on the big matrix, then you have to scan from left to right and top to bottom. You remember that definition of the convolution? Everybody remember that definition? So, now let me do that operation. Look. So, this is a kernel. I put on the image at the left corner, element wise multiplication. Just element wise multiplication, it is written 1 multiplied with minus 1. So, it is minus 1. Next one is multiplied with 1. It is a 1. So, this result of element wise multiplication, I have written here followed by sum divided by n means just I am just it is normalizing I am just normalizing okay is it clear how it comes minus 0.11 is it clear to everybody just first convolution operation I have I have I have ended I put this image tiny image or filter from the left corner, the same size, 3 x 3, the same size, and we did the element wise multiplication followed by summation. Just we are normalizing because there are 9 cells. That's why we are normalizing. There is no other reasons. When you normalize, you will keep the small value. So, total size of matrix, number of pixels in this matrix is 9. That's why I'm multiplying with 9. What is the next step? We have to move your filter to the right. Agree? You remember the definition of the convolution. You need to move the image to the right. So, got it. So, you may have a question, how many pixels you have to move? Is it clear? You can move two pixel at a time, you can move one pixel at a time, you can move the three pixel at a time. Is it clear? So in this case, I have moved one pixel at a time. So this concept we call a stride. Please remember it. Very important terminological introduction. What is the stride? The stride is the number of pixels shift over the input matrix. When the stride is 1, then we move the filter to 1 pixel at a time. When the stride is 2, then we move the filter 2 pixel at a time. So normally we keep stride 1 or 2, we don't keep the stride as a higher size. So everyone is now clear about the stride, what it is, sort of why we did normalization. Total number of matrix. Okay, so question is why we did the normalization. So just making this number smaller side, you can do without the normalization. It will not make much difference. But handling the big number for weight update or for all processing will create a problem. So, smaller number always favorable. Yes, that is only the reason. Otherwise, there is no magic. Okay. Up to this moment, things are clear. Okay. Second question is why we don't keep higher stride, sir? Okay. Okay, what is your purpose of training? Suppose image is given. Very good question. I will fix it here to answer. Somebody asked why stride is not big number. And another question is like stride. And somebody also talked about the kernel size. Agree? So you answer me. you are feeding the image to the any CNN or neural network model. What is your purpose? You tell me. Purpose of training. Answer it. What is the purpose of training? Understand the image. Understand the image. Agree? Very simple. In detail. In detail. Agree? Understand? everybody agree? The CNN during training want to understand the image in detail. So, suppose this is the big image is given. Understand here please. And suppose this is the kernel. I have given this part of image to allow for a feature extraction or this part of image, let the CNN to understand. Agree? So, through the kernel, your CNN is understanding the image. Agree? And what is the right way? If you move slowly, slowly and let the system understand or only this image, portion of the image, you want to be only once, then the next, only once then the next which will be more fruitful you tell me the first version or the second version you give the portion of the image slowly slowly in every iteration let them understand this is the first option in the second option only give the portion of image only once then next portion then next portion so now you tell me the stride will be one will be better or ten will be better you answer it. That's why we keep stride normal small number. Everybody agree logically now? Great. Second people talk about the kernel size. Suppose again same question this is the image suppose 50 cross 50. You can also make a kernel it's up to you technically nobody can stop you 50 cross 50. Agree? So kernel size is your image size is 50 cross 50. Kernel size is 50 cross 50. So how many time convolution operation in this case possible? Image size and kernel size both are same only once. Agree? So how will you learn if only you are allowed to see the image only once? Now, for example, kernel size is 24, 25, cross 25 and suppose there are two kernels, two times. Agree? So, first time kernel will convolutional here, second time kernel will convolutional here. So it is now two time convolutional process will happen. So what is the favorable? the kernel size smaller and let the kernel scan multiple times small, small patches, small, small patches and let that understand in a better way. Is it the right approach or not? You tell me. So too much small is also not good. So normally kernel size, normally we keep it 2 x 2 or normally 3 cross 3. I have handled both the questions. Everybody agree now? This is the intuition and logic to keep stride smaller side and smaller kernel. Because your objective is to understand the image carefully. Great. So come to the mathematical part. So here you just move this kernel with the stride one do again element wise multiplication and you keep the answer here. Agree? Got it? So you need to complete the process like this. So look at here if you have any question please write. Yes, you are correct. Correct, correct. So once this complete scanning is over, you have a resultant matrix at the right hand side, we call it feature map, another terminological introduction. So if somebody will ask what is a feature map, so this is your input matrix, this is your kernel and once convolution operation over the complete image ended, the Resultant matrix or representation, we call it feature map. Yes, yes, Mohit, you are also correct. So this feature, what is a feature map? Please, is it clear to everybody? People are very much confused between feature map, kernel, because they memorize it, they don't understand. So with this diagram, things are very much clear. Once the convolutional operation is over, the resultant matrix, we call it feature map. Now I have a question for you, in the feature map, where is the biggest value, in the feature map, where is the biggest value, here, okay, okay, now, very interesting, very interesting part, very, how the computer learned, how the CNN learned, please focus over here, that was the input image, I think everybody agree, this was the 9 in the image, am I correct, I am going. Am I correct? That was the input. Agree. Wait. This was the kernel. Agree. That was the kernel. And kernel was able to detect. Detect what? Loopy pattern. Wherever this kind of pattern. It can be like this. It can be like this. It can be like this. It can be like is size or not fixed, more or less it will understand, it will detect wherever such loopy patterns are the image. Agree? That was the kernel we have started. Do you remember it? What is the objective? Objective is this kernel. Tell me where is loopy pattern in the input image. Up to this moment everything are clear. Now come to the feature map. Feature map is this. At this place it is the biggest value and other places also have the value but that is a smaller value. So wherever the biggest value means this is the area where the loopy pattern is present. Now you can match with the input image. In the input image, the loopy pattern was at the top side and in the middle. I think everybody agree? It is properly detected. So understand, learning should not be exact. Otherwise, it is overfitting. It is memorizing. memorizing. It will just give you idea, idea of location, idea of a location where loopy pattern exists. Not accurate, just idea. Understand this word. So look, am I correct here? This was the image, input image, 9 was at the top of the middle. So 1 means this is the location in the image where the loopy pattern exists. It is interesting or not? Yes, yes. Very roughly. So, Nisant and everybody, it detects roughly where it is not exactly. Otherwise, it will fail in the real life. Because the cat and dog and other objects are roughly defined. You cannot define with the rules and complete formula. Okay. Now, it's a time to introduce the relu operation, relu activation function. So the moment you apply the relu activation function, we have covered what it does. Wherever the negative values are there, it will make it 0, positive value as it is, agree as it is. So now the feature map, it was and we apply the relu operation, it refine better way. So now we have a two matrix before ReLU operation and after ReLU operation, which is the more cleaner version, you tell me, wherever the patterns are more clear after. And you also observe in the refined version, one is here 0.11, 0.33 also, so means it is not exactly precisely saying loopy pattern is here. pattern may be in that location only you can relate with the input image so it is also some some darker part is here so mathematically it can just extend the location of loopy pattern it is not finding it exactly we want it we don't want a model that exactly learn something from the image because it will fail in the real environment. That is the beauty of ReLU operation. It just cleans and gives the pattern in more visible, more cleaner way in the matrix. It is a hit and try, depend on the problem. Sometimes leaky ReLU doesn't work, sometimes it works. It depends on the problem. All are hit and try. Look, that is the most important slide. The beauty of CNN is what? Once you have a such kind of detector, assume that this kernel or detector is able to detect the loopy pattern, the same kernel can use with any kind of input. Any kind of input. If that input contains the loopy pattern, it will detect. So first case is 9, loopy pattern is at the top, second input image is maybe a 6. If you use this loopy pattern detector with this image 6, it will detect the loopy pattern at the bottom of the image. Input images may have multiple loopy patterns like 8, 2 loopy patterns, it will detect it as it is. Similarly 96, so one loopy pattern with 9, another loopy pattern with 6, it will detect it. So see the power of kernel, how powerful architecture CNN is. Single kernel if you are able to define, able to get it. You can reuse it in any kind of image in the world. For what feature the kernel is defined, it will detect. doesn't matter the image is what kind of it is a cat and dog or or any house or any any any jungle or tree any photo you will give if the feature exists it gives insurity to detect it it is interesting or not so this concept we call once you get the filter you can use the multiple time okay so yeah now focus over here Like we have seen, we will require many such filters. One filter only just detects only one pattern from the images. But images have many, many, many, many features. So assume that. Again, I am saying assume that. This is one filter that can detect will kernel matrix vary. normally in in one architecture we keep the kernel matrix uh the same for all the filter but the it's up to you then if you are interested to change the size of the filter you can do it it's up to you technically there is no any problem yes loopy pattern means roughly it should be a Yes, circular is circular shape, roughly. Yes, Anu Jai, yes. It can have an impact on it. Yes, answer is yes. So what kind of data set is given to you? Accordingly, you need to train your filter. So what non-loopy filter is 7? So that filter will not detect anything. Abhishek is asking if suppose image is 7, okay? So what is the problem? if loopy filter is not there then loopy kernel will not detect it so in this case matrix will be weird so just I am asking this question suppose input is 7 ok and I am just applying the kernel that is for loopy pattern ok you tell me how the feature map will look like this is the feature It is a feature map. You give me the answer. After the conversion operation, this is the feature map. How it will look like? No, no. Yeah, it will be around 0, 0. Around 0, 0. Simple answer. There is no mathematics. If there is no loopy pattern, how you can detect it? Simple answer. You cannot detect it means there will be no any bigger value. There is no location. So it will be 0, 0, 0. What is the problem? Simple mathematics. Got it? So look here. This beauty. But if you want to detect the 9 as a digit. Understand the question. 9 as a digit. You want to classify. And now I am going to change the problem. My objective is not only to detect where is the circular pattern. No, my objective is to classify this image. So I need to understand this image completely. For that case, we required many filters. Again, assume that we have a filter loopy pattern filter that will detect the loopy pattern. We have another filter that is able to detect the vertical line roughly. We have another kernel that can detect the diagonal line. So apply each filter individually, then combine the results. So this is the feature map after applying this loopy pattern filter, assume that. And this is the feature map after applying the vertical lines, where is the vertical line in the input image 9? I think it is detected at the middle of the image roughly, roughly okay. Similarly, where is the diagonal line in the input image at here? So are you agree, roughly the feature maps are clearly giving the location of the feature detected by the feature map. Give me one minute, okay sorry, so the question was are you agree with this one? We have here three filters for the three features they have detected perfectly, got it. Now combine it. So 9 is the input image, you have n number of filters, the three filters are there, they apply together and these are the feature map once you combine it. Once you combine it, then the CNN model will start learning the shape of the 9, how 9 look like. Got it? Got it? It's a pattern recognition. Through the combinations of the feature map, giving millions of input images, your CNN will learn this is a shape of 9. Accordingly, it will learn the pattern of all the input images. Got it? The question is, so here we are having three filters for detecting complete number no there will be many filters this is an example there should be many filters by using the three filter you cannot detect it okay okay so now million dollar question i think there is a big confusion who is going to give the filter you answer me who is going to give the filter correct filter user defined means random value User define means filter having the random value. Okay. How do you know this filter will learn the loopy pattern? Another filter will learn the vertical line. How do you do it? Yes, SORAP is given the correct answer. Not predefined at all. Otherwise, where is the training? Okay. Somebody is saying predefined. so so so what weight you are going to update what weight you are going to update otherwise if already predefined if already predefined then why training is needed you tell me then why training is needed got it yes answer already i have given what is cnn what is cnn understand this word automatic feature extraction. Got it? So, initially what happened? Just randomly you need to define many filters. Okay, it comes with the experience suppose you have n number of filters. Agree? Suppose all are same size. Agree? Random values. These are the random values. This is nothing but simply weights. Value of filters are nothing but simply weights. Agree? Got it? Now during training you need to feed the image. Suppose it is a cat. It will multiply with this filter, multiply with this filter, multiply with this filter, multiply with this filter. At the end, all the features put together in one vector. Then we classify, suppose dog, so it is a misclassification or not. So we need to update it. What? What we are going to update? All the filter weights, all the filter weights, all the filter weights, all the filter weights. It happens many, many, many, many times because CNN training is very complex. A lot of images and a lot of many epochs are required. Ultimate once training is over. Once training is over, what we get? We get trained filter. We get the trained filter. And one of the filter, maybe we don't know for a loopy pattern. One of the filter may be for a vertical line, horizontal line like that. We don't know. It is learned by the CNN. So, it is not your responsibility to find the accurate filter. It comes through the training. Got it? Or there is a relationship between filters. So, those filters also related to each other. Very interesting. related to each other. There is some logical ordering. For example I will explain some of the filter will detect like intensity, some of the filter will detect loopy pattern, some of the filter will detect line and if you combine such many filter you can detect the eye. Agree? Similarly such filter you can detect the The small small features from the face if you start combining you can detect the eye of the given image. Agree? So filters are need to be arranged automatically it will learn. Okay and suppose we have a nose and you put together, put together what it will create? It will create the face. Similarly body, similarly hand, similarly hand, it will detect the body. Got it? It's a very complex process. The very simplest way I am explaining. So many filters will be there. During training, it will learn automatically. Filters will be arranged in logical order so that we can learn the high level features. Eye is also a feature. Nose is also a feature. They are high level features or intensity, line or curve or the low level features. Yes, look this is the example. So this is the one animal. We have a collection of many filters that will detect the eye. Collection of many filters that will detect the nose, ears, hands and legs. They will arrange like eyes, nose and ears. These are the high level features. They arrange in logical order. It will detect the head, body, combine it. It's a one animal. This is the way the CNN looks the input images. Okay, so now we have a next operation, pooling. Okay, so pooling is still we haven't changed the size of input images like we were discussing with the ANN, size of images very huge, a lot of weights are there and ANN is not able to handle it. The same problem is here. So we need to down sample the image. We need to reduce the size of the image. We need to compress the image. So this is the concept comes under the pooling. So what is happening? The pooling layer, main purpose of the pooling layer is to progressively means multiple times you have to apply these operations to reduce the size of the input image. And here we also call it down sample. So polling is nothing but a down sampling of the images. So there are various kind of polling like max polling, average polling. Let me explain one. So this is the bigger idea. What happened in the CNN image as an input we need to apply the convolution operation, ReLU, feature map and polling. This is one block. What we call it? We call it one block. So it depends on the requirement. It is user defined how many such blocks are required to understand the input image. If input image is so complex, the object that you are looking to learn is so complex, many such blocks will be required. Okay, if input image is simple like a black and white or gray scale that we have seen in the human return digit recognition. So, we consider these are the simplest images. So, we require hardly two or three such blocks. So, this is the blocks concept. Each block contain the convolutional operation, ReLU operation, feature map and pooling. Got it? Yeah. So yeah, like already I have covered it. Let me explain about the pooling. So we apply the pooling where? You see this line, feature map. So after the convolutional and ReLU operation, we have a feature map. We apply the pooling operation on the feature map. So suppose this is the feature map. In the pooling operation, again we have a concept of filter and the stride. But this is not filter as we have seen earlier. This, the pooling, we need to define only the matrix size. What do you have to define only? And we don't have any separate matrix. So don't get confused. Pooling means the portion of the feature map you need to process at a time. We don't have any separate matrix as we have seen in the kernels, agree? So don't get confused, pooling means what? This is the feature map, you need to define the size of the pooling, suppose 2 x 2. So we have to, in the same way we have to scan from left to right and top to bottom and stride up to u, suppose this case stride is 2. So, 2 x 2 portion I have taken from the feature map. Agree? So, this is 2 x 2. And suppose it is a max pooling. So, in this 4 options, 5, 1, 8 and 2. Which is the biggest value? You tell me. Which is the biggest value? Yes. So, I have kept out of these 4 options, I have taken most permanent value. I don't need these four values. Too much detailing, learning from the image is also not good. So for that portion of the image, I am taking the most permanent value that is 8. Stride 2, that's why we need to move 2 pixel at a time. So this is the next. Portion 3, 4, 9, 2. So I have taken the 9. Then go to top to bottom, 2 is 2 pixel at a time. So, this is a green color portion, biggest value is 3, similarly 2. Agree? So, look how we have reduced the size of feature map by using the pooling operation. So, this is the now input image to the next convolution operation. Got it? This, after pooling, it will give you some output. This output will go to the next block B2. Same convolutional operation, same feature map, same pooling. Then again, and again, and again, and again. So slowly, slowly, what it is going to do? This picture itself very much clear. Starting with the big image, and progressively you are learning the features and making the image smaller, smaller, smaller, smaller, smaller. So in every step, you are reducing the size of image. Got it? Yeah, this is max pooling, because out of four options, you are considering the biggest value. That's why it's max pooling. Similarly, you can do the same thing by stride 1. Same example. That was the image we have taken. This is a real feature map. You remember? This is a real feature map. Yeah. This feature map I have taken. So look and apply the 2x2 pooling with stride 1. So this is the answer. Bigger stride means you are reducing a lot. Smaller stride means your reduction in the size will not be that much. Hit and try. Answer is Nissan hit and try. There is no fixed rule at all. If the stride one max pooling sometimes works for some application, it may fail for another. Yeah, mostly the CNN has shown its powerful performance with the images and the videos. Okay, wherever the images and videos are out input, the CNN performed excellent. Okay, so this is the complete picture I have given. Similarly, yes, yes, yes, max polling, I have covered it. Okay, so what is the beauty I want to show? Look here, the location of the object doesn't make any difference. Now you could understand properly, if 9 is not at the middle, it may be in the left corner. Since it is not sensitive to the location, these filters, even those filters will detect where it is on loopy pattern 9. It is at the left corner, it can detect it. So now you can confirm with example, the location of the object is not problem with the cnn okay that is one of the most powerful feature of the cnn wherever it is object in the image it will be detected yes now you can give the ann or any other classifier any other classifier the purpose of the cnn is for feature detection only yes yes mohi anuja okay so it is a okay you can do it it's a lot of video a lot of steps are there a lot of books are there you can hit and try. A lot of stuff about the grid search, random search to find the best way. A lot of things are there. Or maybe optimization is one course. I remember. It should be in your course in the next semester. Okay? So Anuja, whatever you have written, it comes under the optimization. Got it? So, I know in the next semester or next to next semester, there should be one subject or maybe let you optimize this okay so like another instead of going for the max pooling you can go with the average pooling it's up to you sometime it works sometime it doesn't work but you have option of max pooling mean pooling and average pooling so it is example of average pooling similarly you have a may have a mini mean pooling it is it is useful Anuja it is very important to find the suitable parameter. Yes, it's very important. I don't know. Obviously, I can't promise it. I don't know. So benefit of the pooling? Yes, it's a hyper-parameter tuning, we call it. In every possible value of parameter like max pooling, average pooling, filter size, optimizer, everything you have to change it and see in which setting it works best for you. So model fitting takes a lot of time. So answer is sort of yes. A lot of possible value you have to hit and try with other combinations. In average pooling, we just do the average of all four values. 5, 1, 8, 2. Average is 4. In the max pooling, we keep only maximum value. That is a simple mathematics. So it's a benefit of the pooling. I don't need to explain because during the discussion I have covered how the max pooling help us. And role of convolution operation, role of ReLU, role of pooling, already I have covered it. and yes, it does not make. Okay, so these are very important parts. So during the image augmentation, you need to rotate or scale your image. So rotation and scaling of the image will help your CNN model to learn the variety of the images that may need to process during the real time. So what is the guideline? Normally good practice. The given data set, you just do the image augmentation by rotation by scaling, then go for the training. It will help for a better training process. Okay, so it is about the CNN. Now you have, I'm just suggesting scaling means changing the size, changing the size of image. at the data set level. We call it scaling. So it's up to you now because the sky is the limit. You can go for other advanced model like ImageNet, .NET or a MobileNet, YOLO. It is not in course, maybe in the future because it is a two-year course for you. So all the content cannot be covered in this first semester course. So a lot of subjects will be in the next semester to the next semesters where you will be given opportunity to learn a lot so but if you have interest you can learn other advanced deep learning model at your end so CNN I have covered in detail okay so next plan is next class I will try to touch upon the RNN so my next target is what RNN CNN is over now it's about RNN I will cover in the next class Anujair, just search in Google. I don't have any book. I don't follow any book. Just search in Google. Whatever you want, you will get it. All the books, videos, code, stuff, all are there. I don't have any particular book or notes so that I can share with you. Okay, so I will ask of one of my students, Asis, I think he will cover about the time series data, about the time or sequential model. I have invited him to cover that part. So maybe next to next class, I will request to the Asis to cover that part in detail. You will enjoy that discussion. okay so it's it's time is over thank you very much we will start RNN in the next class thank you