1
00:00:00,090 --> 00:00:03,420
Now, let's move on to building of a model in Paris.

2
00:00:03,930 --> 00:00:09,750
So if you recall from those slides in our previous pay to watch lesson, this is a CNN model that we're

3
00:00:09,750 --> 00:00:10,410
about to build.

4
00:00:10,800 --> 00:00:11,910
We take the input image.

5
00:00:11,910 --> 00:00:13,650
We have tree by tree filters.

6
00:00:13,950 --> 00:00:18,480
We get it to the twenty to twenty two feature map set of 26 by 26.

7
00:00:18,780 --> 00:00:20,370
Then we have another conflict.

8
00:00:20,760 --> 00:00:22,900
So we actually use a tree battery filter there.

9
00:00:23,310 --> 00:00:25,080
And then we get these feature map sort of it.

10
00:00:25,080 --> 00:00:26,760
We use 64 filters in that case.

11
00:00:26,760 --> 00:00:28,590
So now we get 64 feature maps.

12
00:00:28,950 --> 00:00:31,890
We apply réélu activation layers to these.

13
00:00:32,280 --> 00:00:33,440
Then we have a max pool.

14
00:00:33,450 --> 00:00:35,190
We also play re-look to this as well.

15
00:00:35,610 --> 00:00:38,520
We have 12 by 12 because it's half that size.

16
00:00:38,520 --> 00:00:39,480
We have 64.

17
00:00:39,510 --> 00:00:43,530
Because the 64 filters flatten it for the connected layer.

18
00:00:43,560 --> 00:00:48,900
All of these nodes are connected and upwards to the soft max, which is the output, and we get the

19
00:00:48,900 --> 00:00:50,100
probabilities out of it.

20
00:00:50,700 --> 00:00:56,580
So in Keros, it's actually quite easy to construct complicated CNN's.

21
00:00:57,120 --> 00:01:00,750
So these are just some details of what we're doing here, what I just went over.

22
00:01:01,200 --> 00:01:03,990
Now let's take a look at the code where we actually build our CNN.

23
00:01:04,530 --> 00:01:06,780
So it's quite a lot of text to have.

24
00:01:06,780 --> 00:01:09,240
There's a lot of comments that explain what we do.

25
00:01:10,170 --> 00:01:15,030
So it would be helpful if you paused sometimes or just take a look at your own notebook and go through

26
00:01:15,030 --> 00:01:15,870
this on your own.

27
00:01:16,470 --> 00:01:17,920
So these are the inputs here.

28
00:01:17,940 --> 00:01:23,070
So in Keros, when TensorFlow, we have to import all of the objects.

29
00:01:23,430 --> 00:01:26,640
These are the building blocks of the layers that we would be using and see it in the CNN.

30
00:01:27,180 --> 00:01:33,030
So we have the sequential sequential basically says that we're building a sequential model, which means

31
00:01:33,030 --> 00:01:35,100
that it's each layer is connected to the next.

32
00:01:35,700 --> 00:01:38,700
Then these are two of the model is building as well.

33
00:01:39,120 --> 00:01:40,530
From the layers library.

34
00:01:41,040 --> 00:01:44,940
We have then struck out flatten builds have convex pool.

35
00:01:44,940 --> 00:01:47,950
This can all be in one layer, but is just on two lines.

36
00:01:47,970 --> 00:01:53,880
So to make it shorter, Keros we import the back end is key because we occasionally need to access that.

37
00:01:54,390 --> 00:01:58,920
And then we have this stochastic gradient descent from the as part of the library.

38
00:01:59,490 --> 00:02:05,100
So we have all of the building blocks we need if we imported them and look how easy this is in the US

39
00:02:05,100 --> 00:02:10,620
to construct a model with this new model dot ad after we create the model up here.

40
00:02:11,430 --> 00:02:13,020
We added a clumsily are here.

41
00:02:13,020 --> 00:02:19,410
We specify how many filters we specify the kernel size here, tree by tree specify the activation we

42
00:02:19,410 --> 00:02:26,580
want to use redo and input shape, which is input shape we took from up here or there.

43
00:02:26,580 --> 00:02:26,880
Was it?

44
00:02:27,600 --> 00:02:32,400
Yeah, up here 28 by 28 comma one, which is the depth of the image.

45
00:02:34,080 --> 00:02:34,920
And that's it.

46
00:02:35,220 --> 00:02:37,290
So we just cleared of this conflict.

47
00:02:37,830 --> 00:02:39,960
Let's make our second conflict now.

48
00:02:40,380 --> 00:02:41,070
So now we can.

49
00:02:41,070 --> 00:02:44,610
We want to make a 64 filter tree by tree kernel size.

50
00:02:45,090 --> 00:02:46,920
We don't actually have to write content, says Eq..

51
00:02:46,920 --> 00:02:47,220
You can.

52
00:02:47,550 --> 00:02:52,920
The function knows that a second parameter is going to be kernel size, and then we specify the activation

53
00:02:53,720 --> 00:02:56,080
activation layer again using real.

54
00:02:56,520 --> 00:02:58,500
Now you may have wondered why we didn't.

55
00:02:58,710 --> 00:03:01,060
We didn't need to set padding or straight.

56
00:03:01,060 --> 00:03:08,670
If we can, we can actually add in a padding or straight parameter, like putting padding equal to one

57
00:03:08,670 --> 00:03:09,300
or two.

58
00:03:09,810 --> 00:03:15,450
However, we using a default values and default values, we didn't use any padding and we used stride

59
00:03:15,450 --> 00:03:17,280
of one for both conflicts.

60
00:03:17,970 --> 00:03:20,100
Next, we use a max boot again.

61
00:03:20,550 --> 00:03:27,600
And similarly, with Max boot, we can specify inside here we could put Stride Eq. four or whatever

62
00:03:27,600 --> 00:03:28,410
we wanted to use.

63
00:03:28,950 --> 00:03:32,190
However, we're not going to just yet because we're going to use default one.

64
00:03:33,210 --> 00:03:37,490
So we add the Max Boulia here and then we add the flattened layer here.

65
00:03:37,500 --> 00:03:42,270
We just basically flattened latex the previous input and flattened it.

66
00:03:42,570 --> 00:03:48,960
I notice we don't have to link like have X equal to this and have an input, but would carry us when

67
00:03:48,960 --> 00:03:49,680
we do model it.

68
00:03:49,680 --> 00:03:53,100
Add it adds sequentially each layer.

69
00:03:53,100 --> 00:03:55,350
So we know each layer feeds into the other layer.

70
00:03:56,040 --> 00:04:01,380
And when we do flatten here, it just flattens the output of the Max Boulia right here.

71
00:04:01,590 --> 00:04:05,730
That gives us nine thousand two hundred sixteen by one dimension of that.

72
00:04:06,210 --> 00:04:07,230
Come and take in this.

73
00:04:07,590 --> 00:04:09,750
Think of this next.

74
00:04:10,260 --> 00:04:15,090
We have this dense layer, which is once in twenty eight layers using an activation of rlU again.

75
00:04:15,090 --> 00:04:20,650
So we just take that and feed it into there, take that output and then fit it into the soft max layer

76
00:04:20,650 --> 00:04:22,770
here now in the loss of max layer.

77
00:04:23,010 --> 00:04:28,680
We need to specify the input size and the input size as a number of classes, which is 10, which is

78
00:04:28,680 --> 00:04:30,980
what we set that variable up here.

79
00:04:31,260 --> 00:04:31,540
10.

80
00:04:32,460 --> 00:04:33,960
Consider printed it out just to make sure.

81
00:04:34,710 --> 00:04:38,490
So that's what we need for the soft max layer right now.

82
00:04:39,180 --> 00:04:42,870
And then all we have to do after that is just to model that compile.

83
00:04:43,380 --> 00:04:49,920
This creates an object that stores a model that we just created that's not above the code right there.

84
00:04:51,570 --> 00:04:58,140
So what we do here in the model to compile, we can specify, just like in Potawatomi, specified all

85
00:04:58,170 --> 00:04:59,430
across an arbitrary and.

86
00:05:00,080 --> 00:05:06,440
Entropy, lost function and optimizer, we specify those things here in carrots, we have to attitude

87
00:05:06,440 --> 00:05:11,680
metric here, metric being accuracy, which is what we want to monitor during the training process.

88
00:05:11,940 --> 00:05:17,000
It's quite simple and you can put because it's a list, you can put multiple things here, like if you

89
00:05:17,000 --> 00:05:19,700
wanted to do loss as well, you could have done it like that.

90
00:05:20,570 --> 00:05:21,980
So let's take it out for now.

91
00:05:22,940 --> 00:05:26,570
And then at the end, this is a very good practice that I tend to do a lot.

92
00:05:26,930 --> 00:05:32,630
Print the model of summary and it gives you a breakdown of the little the output shape number of parameters

93
00:05:32,630 --> 00:05:32,900
in it.

94
00:05:33,260 --> 00:05:39,470
And if you remember from all the slides, these were the parameters we got got when we created this

95
00:05:39,470 --> 00:05:40,850
neural net to CNN.

96
00:05:42,140 --> 00:05:47,150
And it gives you the total trainable parameters, total parameters, non-tradable parameters which are

97
00:05:47,160 --> 00:05:48,230
zero in this case.

98
00:05:48,620 --> 00:05:49,520
So it's pretty cool.

99
00:05:49,670 --> 00:05:54,850
So we'll stop there in the next section, though we'll start training on model.

100
00:05:54,860 --> 00:06:00,980
But this here just wanted to show you this is the same could above here without all the comments, and

101
00:06:00,980 --> 00:06:05,150
you can see how short and easy it is to construct that fairly.

102
00:06:05,450 --> 00:06:10,580
I mean, it's not a complicated CNN, it's a basic CNN, but you can see how easy it was to construct

103
00:06:10,580 --> 00:06:14,600
at CNN using cameras right now and defined a loss and optimizer.

104
00:06:14,960 --> 00:06:19,630
So it's quite good, quite nice, and hope you took a lot from this lesson.

105
00:06:20,000 --> 00:06:23,570
In the next lesson, we'll take a look at how we start treating this model.

106
00:06:23,990 --> 00:06:25,280
So stay tuned for that.
