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,560 --> 00:00:15,450
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,860
We first use flatten and layer, then dense, layered with 300 neuron, then dense layer with 100 neurons

4
00:00:23,010 --> 00:00:24,240
and then the output layer.

5
00:00:25,610 --> 00:00:29,220
We are going to add CNN layers before this.

6
00:00:30,810 --> 00:00:35,280
So this is our input, 28 by 28 pixel cross one.

7
00:00:36,390 --> 00:00:42,540
So 28 pixels as well, 28 pixels as height and one as the channel.

8
00:00:45,300 --> 00:00:49,890
We are going to use a filter size of three by three with the straight off one.

9
00:00:52,410 --> 00:00:55,650
And then this will be our convolutional layer.

10
00:00:56,700 --> 00:00:59,340
Since we are using filter size of three where three.

11
00:00:59,820 --> 00:01:02,670
And we are also using a padding as valid.

12
00:01:03,150 --> 00:01:06,110
We are ignoring one pixel from each side.

13
00:01:06,630 --> 00:01:08,070
Since our padding is swelling.

14
00:01:08,550 --> 00:01:17,310
So the convolutional layer, we are going to get this 26 by 26 and to 32, we are going to use 32 different

15
00:01:17,310 --> 00:01:19,800
filters for this convolutional layer.

16
00:01:22,200 --> 00:01:25,390
After this, we are going to use to where to Max, bullying.

17
00:01:27,030 --> 00:01:35,220
So finally, after this corn layer, we are going to get 13 by 13 and to 32 cells in our pooling layer.

18
00:01:37,950 --> 00:01:40,410
Now, we have to add some dense layer as well.

19
00:01:41,310 --> 00:01:45,500
So we have to convert this 3D object into one dimensionality.

20
00:01:45,720 --> 00:01:47,820
So we are using flatten layer.

21
00:01:48,660 --> 00:01:50,790
Then we are going to use to dense layer.

22
00:01:51,120 --> 00:01:52,920
First one with 300 neuron.

23
00:01:53,430 --> 00:01:55,260
And next one with hundred neurons.

24
00:01:56,310 --> 00:02:01,200
And then we are going to use an output layer with 10 neurons.

25
00:02:01,290 --> 00:02:08,790
Since we have to identify ten different classes, the code is almost similar.

26
00:02:09,480 --> 00:02:11,370
First, we have to create a model object.

27
00:02:13,320 --> 00:02:16,800
Then we are going to add the convolutional layer.

28
00:02:18,690 --> 00:02:24,340
We'll write model, dot, add and then get us dot layers, dot com, 2d.

29
00:02:25,740 --> 00:02:28,370
And as parameters, we want to do filters.

30
00:02:29,550 --> 00:02:33,300
We want to have over feature of size three by three.

31
00:02:34,290 --> 00:02:35,190
So we have to grow.

32
00:02:35,270 --> 00:02:38,030
Kernel size has three comma three.

33
00:02:38,580 --> 00:02:42,370
If you want double the size of four, wherefore you can write for pomoc forward.

34
00:02:44,040 --> 00:02:46,080
By default those start value is one.

35
00:02:47,190 --> 00:02:49,590
We are going to use the same.

36
00:02:50,550 --> 00:02:53,220
And we are going to use buiding as valid.

37
00:02:54,390 --> 00:02:56,240
The activation is always relu.

38
00:02:57,990 --> 00:03:00,760
And the input shape is 28.

39
00:03:00,820 --> 00:03:01,710
Cross 28.

40
00:03:01,710 --> 00:03:02,350
Cross one.

41
00:03:03,360 --> 00:03:08,880
If you are dealing with any Collodi images, you have to give values for channel as well.

42
00:03:09,180 --> 00:03:11,520
So for Galardi images, this should be three.

43
00:03:12,870 --> 00:03:17,940
This should be the height, weight and then the number of channels.

44
00:03:19,980 --> 00:03:23,370
So this is a work on layer four or pulling layer.

45
00:03:24,360 --> 00:03:32,180
We can edit using this syntax model a lot and then Gaydos dot layers dot max pulling 2D.

46
00:03:32,850 --> 00:03:37,020
And then here you have to give the dimensions of your window.

47
00:03:37,650 --> 00:03:39,240
We are going to use deceptive.

48
00:03:39,300 --> 00:03:40,680
We love to cross too.

49
00:03:41,020 --> 00:03:44,630
That's why we are giving to comment to as a parameter.

50
00:03:46,410 --> 00:03:51,390
After this, we want to convert our three dimensional matrix into one dimensional matrix.

51
00:03:51,720 --> 00:03:55,220
So we have to use flatten and after flatten.

52
00:03:55,260 --> 00:03:59,470
We can use our dense layers as we did in and then.

53
00:04:00,960 --> 00:04:04,230
So we are adding another layer with 300 neurons.

54
00:04:05,100 --> 00:04:07,480
And then another layer with 200 neurons.

55
00:04:07,800 --> 00:04:12,510
And for both of these layers, we want our activation function to be of RELU.

56
00:04:13,950 --> 00:04:16,470
And the next layer is our output layer.

57
00:04:17,970 --> 00:04:20,340
We want to classify 10 different categories.

58
00:04:20,550 --> 00:04:22,650
That's why we are using 10 neurons.

59
00:04:23,160 --> 00:04:28,200
And that tuition is softmax activation because this is a classification problem.

60
00:04:29,460 --> 00:04:30,780
Now, let's run this.

61
00:04:34,880 --> 00:04:36,230
No, similar to last time.

62
00:04:37,130 --> 00:04:42,260
We can use Dort somebody Martek to get details.

63
00:04:42,350 --> 00:04:44,310
All four were Mortel architecture.

64
00:04:46,880 --> 00:04:53,810
Here you can get information of all the layers or does the shape of those layers and the number of parameters

65
00:04:53,870 --> 00:04:55,340
that you are going to train.

66
00:04:55,430 --> 00:04:57,080
Using this model architecture,

67
00:05:00,740 --> 00:05:07,190
no important thing here you can notice is that the number of parameters we are going to train is in

68
00:05:07,190 --> 00:05:07,820
millions.

69
00:05:09,110 --> 00:05:13,850
So in this dense layer, we have around one point six million parameters to train.

70
00:05:16,910 --> 00:05:23,450
Now, if we have not used Max fulling layer two, this would have been around four million or five million

71
00:05:23,450 --> 00:05:23,870
neurons.

72
00:05:23,870 --> 00:05:32,180
So so using max pooling has significantly reduced the number of parameters that we are going to train

73
00:05:32,950 --> 00:05:33,950
in the next lecture.

74
00:05:34,220 --> 00:05:38,360
We will try to train a model without a pooling layer.

75
00:05:38,810 --> 00:05:45,410
And there we can clearly see the difference in number of parameter and the execution time in the models

76
00:05:45,680 --> 00:05:48,320
with the pulling layer and without the bullying layer.

77
00:05:52,740 --> 00:06:03,150
The next step is to compile the model now, since we have exclusive might be label classification problem.

78
00:06:04,050 --> 00:06:11,950
We are going to use a sparse, categorical and Cross and Groppi and we want to use Optimizer as a study.

79
00:06:12,380 --> 00:06:14,080
So class state, Verdean descent.

80
00:06:14,710 --> 00:06:16,800
And we want to calculate the accuracy.

81
00:06:17,040 --> 00:06:22,230
Since we are doing the classification problem, it's compiled this model.
