1 00:00:00,990 --> 00:00:05,760 Now this is the architecture we are going to use for our CNN model. 2 00:00:07,530 --> 00:00:16,110 If you remember last time when we ran in and model on this problem we used this side of the network. 3 00:00:16,200 --> 00:00:22,850 We first see those flat and layered then dense layered with 300 neuron then dense layer with 100 neurons 4 00:00:23,010 --> 00:00:25,210 and then the output layer. 5 00:00:25,620 --> 00:00:30,810 We are going to add CNN layers before this. 6 00:00:30,810 --> 00:00:40,590 So this is our input vine beard by 28 pixel cross one so twenty 28 pixels as well 28 pixels as height 7 00:00:40,860 --> 00:00:44,150 and 1 as the channel. 8 00:00:45,270 --> 00:00:53,670 We are going to use a filter size of three by three with the straight off one and then this will be 9 00:00:53,670 --> 00:01:01,230 our constitutional layer since we are using for their size of three by three and we are also using a 10 00:01:01,240 --> 00:01:03,150 padding as valid. 11 00:01:03,150 --> 00:01:08,090 We are ignoring one pixel from each side since our padding is valid. 12 00:01:08,550 --> 00:01:15,150 So the convolution layer we are going to get is 26 by 26 and 32. 13 00:01:15,150 --> 00:01:22,830 We are going to use 32 different filters for this constitutional layer after this. 14 00:01:22,830 --> 00:01:26,880 We are going to use to wear to Max pooling. 15 00:01:26,950 --> 00:01:37,870 So finally after this one layer we are going to get 13 by 13 and to 32 cells in our pooling layer. 16 00:01:37,920 --> 00:01:45,570 Now we have to add some dense layer as well so we have to convert this 3D object into one dimensionality. 17 00:01:45,720 --> 00:01:53,570 So we are using like 10 layer then we are going to use two dense layer first one with 300 neuron and 18 00:01:53,590 --> 00:02:01,320 next one with hundred neurons and then we are going to use an output layer with 10 neurons. 19 00:02:01,320 --> 00:02:04,260 Since we have identified 10 different classes 20 00:02:07,140 --> 00:02:09,470 the code is almost similar. 21 00:02:09,480 --> 00:02:13,320 First we have to create a model object. 22 00:02:13,320 --> 00:02:23,370 Then we are going to add a convolution a layer will write more than dot Ed and then get us dot layers 23 00:02:23,400 --> 00:02:27,050 dot com 2D and as parameters. 24 00:02:27,060 --> 00:02:33,370 We want to do for readers we want to have over a reader of size three by three. 25 00:02:34,290 --> 00:02:38,540 So we have to grow a kernel size has three common three. 26 00:02:38,580 --> 00:02:45,290 If you want to print that size of four wherefore you can write four comma four by default the state 27 00:02:45,300 --> 00:02:47,010 value is one. 28 00:02:47,160 --> 00:02:56,260 We are going to use the same and we are going to use padding as valid the activation is always a loop 29 00:02:57,990 --> 00:03:03,090 and the input shape is 28 across 28 Cross 1. 30 00:03:03,330 --> 00:03:09,140 If you are dealing with any collateral images you have to give values for channel as well. 31 00:03:09,180 --> 00:03:12,890 So for blurred images this should be three. 32 00:03:12,900 --> 00:03:19,900 This should be the height weight and then the number of channels. 33 00:03:19,980 --> 00:03:24,310 So this is our common layer for our pooling layer. 34 00:03:24,360 --> 00:03:32,220 We can edit using this index model a lot and then get us dot layers dot Max pulling 2D. 35 00:03:32,850 --> 00:03:37,630 And then here you have to give the dimensions of your window. 36 00:03:37,650 --> 00:03:40,950 We are going to use this app if we love to cross through. 37 00:03:41,010 --> 00:03:45,120 That's why we are giving to common to as a parameter here. 38 00:03:46,410 --> 00:03:51,560 After this we want to convert our three dimensional matrix into one dimensional matrix. 39 00:03:51,720 --> 00:04:00,690 So we have to use light then and after light and we can use our dense layers as we did in and then. 40 00:04:00,960 --> 00:04:07,790 So we are adding another layer with 300 neurons and then another layer with hundred neurons. 41 00:04:07,800 --> 00:04:15,510 And for both of these layers we want our activation function to be of three low and the next layer is 42 00:04:15,510 --> 00:04:17,830 our output layer. 43 00:04:17,940 --> 00:04:20,550 We want to classify 10 different categories. 44 00:04:20,550 --> 00:04:27,780 That's why we are using 10 neurons and that activation as soft Max activation because this is a classification 45 00:04:27,780 --> 00:04:29,410 problem. 46 00:04:29,460 --> 00:04:30,780 Now let's run this 47 00:04:34,390 --> 00:04:36,240 no similar to last time. 48 00:04:37,140 --> 00:04:45,800 We can use dots somebody Medtech to get details of our model architecture. 49 00:04:46,890 --> 00:04:49,690 Here you can get information of all the layers. 50 00:04:49,690 --> 00:04:56,070 What is the shape of those layers and the number of parameters that you are going to screen using this 51 00:04:56,070 --> 00:04:57,080 model architecture 52 00:05:00,520 --> 00:05:01,150 now. 53 00:05:01,170 --> 00:05:08,260 Important thing here you can notice is that the number of parameters we are going to train is in millions. 54 00:05:09,120 --> 00:05:16,490 So in this dense layer we have around one point six million parameters to train. 55 00:05:16,890 --> 00:05:23,880 Now if we have not used Max pulling layer 2 this would have been around 4 million or 5 million neurons 56 00:05:23,880 --> 00:05:31,860 so so using max pulling has significantly reduced the number of but I might add that we are going to 57 00:05:31,860 --> 00:05:34,200 train in the next lecture. 58 00:05:34,200 --> 00:05:41,460 We will try to train a model without a pooling layer and there we can clearly see the difference in 59 00:05:41,460 --> 00:05:48,060 number of parameters and execution time in the models with the pulling layer and without the bullying 60 00:05:48,060 --> 00:05:48,300 layer 61 00:05:52,730 --> 00:05:57,650 the next step is to compile the model. 62 00:05:57,650 --> 00:06:06,150 Now since we have exclusive might be label classification problem we are going to use sparse categorical 63 00:06:06,430 --> 00:06:08,850 and cross and copy. 64 00:06:08,910 --> 00:06:14,540 And we want to use optimizer as a sturdy stochastic gradient descent. 65 00:06:14,720 --> 00:06:20,880 And we want to calculate the accuracy since we are doing the classification problem. 66 00:06:20,880 --> 00:06:22,220 Let's compile this model.