1
00:00:00,450 --> 00:00:05,970
Now, that said, we have this feature, our feature extractor.

2
00:00:05,970 --> 00:00:09,030
So we have feature extractor right here.

3
00:00:09,150 --> 00:00:13,440
And then this inherits from layer.

4
00:00:13,440 --> 00:00:24,750
So you inherit from TensorFlow layer and then we have and you need method and followed by a call method.

5
00:00:24,990 --> 00:00:26,100
So that's it.

6
00:00:26,130 --> 00:00:28,250
Now let's use the right syntax.

7
00:00:28,260 --> 00:00:29,620
Here is a class.

8
00:00:29,640 --> 00:00:32,850
Here is a method init method.

9
00:00:33,540 --> 00:00:34,560
There we go.

10
00:00:34,920 --> 00:00:42,420
You could always check on our free cars on python programming in case you are not versed with all this

11
00:00:42,420 --> 00:00:43,200
syntax.

12
00:00:43,200 --> 00:00:44,010
So that's it.

13
00:00:44,010 --> 00:00:45,180
We have had that.

14
00:00:45,180 --> 00:00:50,880
And now, just like the way we did when we were creating this feature extractor, let's go back to our

15
00:00:50,880 --> 00:00:56,850
feature extractor with a functional API actually here, you'll see.

16
00:00:56,850 --> 00:01:01,740
Let's copy this out and then get back to our model subclasses.

17
00:01:02,190 --> 00:01:04,800
So that's it here.

18
00:01:05,010 --> 00:01:06,960
Let's just put this down here.

19
00:01:07,890 --> 00:01:14,040
Then we have the super feature extractor.

20
00:01:15,240 --> 00:01:16,140
There we go.

21
00:01:16,140 --> 00:01:17,760
That init.

22
00:01:19,140 --> 00:01:19,930
So that's it.

23
00:01:19,950 --> 00:01:29,130
Now that we have defined this, we could go ahead and use this layers as the attribute for this feature

24
00:01:29,130 --> 00:01:30,330
extractor layer.

25
00:01:31,020 --> 00:01:32,070
So there we go.

26
00:01:32,070 --> 00:01:42,870
We have this year we have our conf the self de self dot com one which is this conf to dx right here.

27
00:01:42,870 --> 00:01:46,710
So we take all this off and just place it here.

28
00:01:46,710 --> 00:01:56,700
And then from here we have the batch batch one which is this batch nom layer right here, take this

29
00:01:56,700 --> 00:02:02,610
and then place it right here we have the max pull to DX, take that off.

30
00:02:02,910 --> 00:02:08,190
We have self dot pull one.

31
00:02:08,670 --> 00:02:09,510
There we go.

32
00:02:09,510 --> 00:02:10,350
So that's it.

33
00:02:10,350 --> 00:02:18,580
And then we just repeat this process so we could have the self that comes one come to rather so come

34
00:02:18,630 --> 00:02:22,760
to and then we just take up this parameters.

35
00:02:22,770 --> 00:02:28,410
Let's take this from here and uh, place it right here.

36
00:02:28,620 --> 00:02:34,440
So here, instead of having this, we just get this, and then the batch normal Max puts would remain

37
00:02:34,440 --> 00:02:35,100
the same.

38
00:02:35,100 --> 00:02:37,230
So that's it for our init method.

39
00:02:37,230 --> 00:02:41,250
We now go ahead to build our call method.

40
00:02:41,250 --> 00:02:51,390
We have our call method here which takes this input x, and then here what it does is it permits us

41
00:02:51,390 --> 00:02:57,720
call each and every layer we've defined here in this init method.

42
00:02:57,720 --> 00:03:03,600
So here we have x equals self, so the value of x is going to change.

43
00:03:03,600 --> 00:03:08,760
We're going to pass it to self dot, conf one and several conf one is going to take an x.

44
00:03:08,760 --> 00:03:15,750
This looks similar to the functional API we have x equals self dot batch one.

45
00:03:16,230 --> 00:03:34,590
There we go, batch one and then we have x equals self dot pool 1xx equals self dot com to x and then

46
00:03:34,590 --> 00:03:37,470
self dot batch two.

47
00:03:38,730 --> 00:03:44,190
And finally we have self dot pool two.

48
00:03:45,090 --> 00:03:45,630
That's it.

49
00:03:45,630 --> 00:03:48,060
So now from here we just return x.

50
00:03:48,570 --> 00:03:56,160
Also note that we could pass in a parameter an argument like the training which can tell us whether

51
00:03:56,160 --> 00:04:01,140
to use a given layer or not doing the training process.

52
00:04:02,160 --> 00:04:04,980
Nonetheless, for now, all this is going to be used or in training.

53
00:04:04,980 --> 00:04:06,030
So we have that.

54
00:04:06,330 --> 00:04:08,130
Now let's take all this off.

55
00:04:10,050 --> 00:04:11,120
We run that.

56
00:04:11,130 --> 00:04:12,240
There we go.

57
00:04:13,200 --> 00:04:14,570
That's run correctly.

58
00:04:14,580 --> 00:04:17,100
Now we should be able to build our model.

59
00:04:17,100 --> 00:04:22,590
So here we have this little net model which took the feature extractor model from here.

60
00:04:23,310 --> 00:04:24,750
Let's just copy this.

61
00:04:24,900 --> 00:04:30,720
And then but before copying that, we have to ensure that we create this here.

62
00:04:30,720 --> 00:04:34,200
So we have future subclass.

63
00:04:34,560 --> 00:04:40,740
So we have our feature subclass, which is this feature extractor built right here.

64
00:04:41,460 --> 00:04:45,810
So yeah, we have feature extractor build.

65
00:04:45,810 --> 00:04:46,700
So that is it.

66
00:04:46,710 --> 00:04:54,180
Now you could always pass this parameters like the number of filters they cannot size via this.

67
00:04:54,180 --> 00:04:59,400
So you could pass this here, you could specify filters and and the kernel.

68
00:04:59,530 --> 00:05:00,310
Sighs.

69
00:05:00,310 --> 00:05:01,570
So let's let's just do that.

70
00:05:01,570 --> 00:05:11,950
So let's say filters, text, kernel size stripes and say pattern and activation.

71
00:05:11,950 --> 00:05:17,950
So we could pass all this here so that when we get to this point, we just we don't need to specify

72
00:05:17,950 --> 00:05:18,700
all this.

73
00:05:19,240 --> 00:05:25,330
So we'll simply take this off or no need to specify all this anymore.

74
00:05:26,320 --> 00:05:29,710
Now we have our activation, all that specified.

75
00:05:30,160 --> 00:05:32,920
Okay, We could also include a pool size.

76
00:05:33,670 --> 00:05:38,860
Let's include a pool size and all this right here.

77
00:05:39,220 --> 00:05:43,840
So let's just say, yeah, we're going to have two times the strikes because we to specify the strikes

78
00:05:43,840 --> 00:05:45,040
to be one.

79
00:05:45,040 --> 00:05:47,260
So let's take this off here.

80
00:05:47,260 --> 00:05:52,780
We're going to have two times a strikes and we've defined yeah, we have the pool size.

81
00:05:53,020 --> 00:06:01,090
So let's take this off and take let's take this off rather like let's get back.

82
00:06:01,450 --> 00:06:05,160
So we take this off and take this off.

83
00:06:05,200 --> 00:06:06,130
So that is it.

84
00:06:06,130 --> 00:06:11,080
We've defined all that and now we are ready to pass all those values.

85
00:06:11,080 --> 00:06:17,800
So we just simply copy all those values and then in-year, we specify the number of filters.

86
00:06:17,800 --> 00:06:24,960
So yeah, let's take eight, the kernel size, let's take three, the number of strikes we have one.

87
00:06:24,970 --> 00:06:34,510
The pattern here is valid, valid activation value, pool size is two.

88
00:06:34,660 --> 00:06:35,470
So that's it.

89
00:06:35,620 --> 00:06:37,570
So we've defined all this.

90
00:06:37,600 --> 00:06:41,500
Now, at this point, let's ensure that we have this times two.

91
00:06:41,770 --> 00:06:44,590
So let's run this now again.

92
00:06:44,590 --> 00:06:50,670
And then we have our feature extractor, but we get in this error.

93
00:06:50,680 --> 00:06:55,030
Let's try to understand why and how to solve this error.

94
00:06:56,200 --> 00:06:57,490
So there we go.

95
00:06:57,490 --> 00:06:58,300
Scrolling.

96
00:06:58,300 --> 00:06:59,500
We have this.

97
00:06:59,530 --> 00:07:07,780
Now, the reason why we have this error is because of the order in which this comes to the Texas arguments.

98
00:07:08,470 --> 00:07:14,950
So if you look at this, trying to get this to come up anyway, we just look at the documentation.

99
00:07:14,950 --> 00:07:20,080
You see we have filters, kernel size strikes, pattern data format.

100
00:07:20,080 --> 00:07:26,010
So you see we have the data format, select the dilation rate groups before the activation.

101
00:07:26,020 --> 00:07:33,610
So it's important that we specify that this is filters, equal filters, and then we specify kernel

102
00:07:33,610 --> 00:07:33,970
size.

103
00:07:33,970 --> 00:07:38,650
Equal kernel size, if not is going to take this to be the data format.

104
00:07:38,950 --> 00:07:47,590
So that's it strikes pattern, equal pattern and activation, equal activation.

105
00:07:47,740 --> 00:07:48,970
So this should be fine.

106
00:07:48,970 --> 00:07:56,380
Now we run that again, we have this error, but this time around for the second conf layer.

107
00:07:56,380 --> 00:08:04,300
So let's, let's just redo what we had done here and take this off notice filter size times two.

108
00:08:04,300 --> 00:08:10,930
So here we have filters, times two, we try to do same for the max pull through.

109
00:08:10,930 --> 00:08:21,160
DD So yeah, we have pull size, equal pool size, that's it strikes, that's fine.

110
00:08:21,160 --> 00:08:25,570
And then yeah, we have pool size, equal pool size.

111
00:08:25,960 --> 00:08:28,840
Okay, So now everything should work fine.

112
00:08:29,050 --> 00:08:32,350
We run that and there we go.

113
00:08:32,350 --> 00:08:33,430
Everything works fine.

114
00:08:33,610 --> 00:08:38,920
So now we've created our layer, our feature subclass layer.

115
00:08:38,920 --> 00:08:44,230
We will now be able to use it in this model right here.

116
00:08:44,230 --> 00:08:51,190
So let's copy that and then get back to this or paste this out here and now.

117
00:08:51,190 --> 00:08:59,860
Here we have our feature subclass, Let's take all this off subclass and then we could comfortably run

118
00:08:59,860 --> 00:09:03,520
this and we get in this error.

119
00:09:03,550 --> 00:09:05,320
Now let's get back to check.

120
00:09:05,650 --> 00:09:07,180
We see batch two.

121
00:09:07,210 --> 00:09:09,310
There's an error level, batch two.

122
00:09:09,670 --> 00:09:15,160
Now you see here we have this two, it should be two and this should be two.

123
00:09:15,160 --> 00:09:16,300
So that's fine.

124
00:09:16,480 --> 00:09:19,810
Let's run that again and everything works well.

125
00:09:19,810 --> 00:09:25,780
So you see, it gives us that same output we expect to get with this feature extractor right here.

126
00:09:27,040 --> 00:09:33,370
Then one last thing we could do is instead of doing this way, let's insert some code.

127
00:09:33,370 --> 00:09:40,570
Instead of doing this way, we are going to create a model using this model subclass method.

128
00:09:40,930 --> 00:09:44,260
So here we just copy this out.

129
00:09:45,280 --> 00:09:46,630
So we copy that out.

130
00:09:46,630 --> 00:09:50,950
And then in here instead of having layers.

131
00:09:50,950 --> 00:09:54,070
So yeah, we not have a layer, we have an A model.

132
00:09:54,220 --> 00:09:59,200
So instead of having a layer, we now have model and then we're going to do.

133
00:09:59,330 --> 00:10:02,660
Find a feature extractor.

134
00:10:02,660 --> 00:10:09,830
So our feature extractor now is going to be the feature extractor we've just defined here.

135
00:10:10,160 --> 00:10:12,550
So let's go up and there we go.

136
00:10:12,560 --> 00:10:16,760
So we just we're going to get this feature extractor right here.

137
00:10:16,760 --> 00:10:20,750
And then what we do is we put it in your.

138
00:10:20,960 --> 00:10:23,120
So let's take all this off.

139
00:10:23,690 --> 00:10:27,380
We have all this off that's now our feature extractor.

140
00:10:27,380 --> 00:10:30,470
So we've got got this feature extractor.

141
00:10:30,680 --> 00:10:31,460
That's it.

142
00:10:31,460 --> 00:10:37,590
And then once we get X, we're going to pass this through a feature extractor.

143
00:10:37,610 --> 00:10:38,420
There we go.

144
00:10:38,930 --> 00:10:41,720
Let's take all this off and we'll find.

145
00:10:42,980 --> 00:10:45,170
Now we're done with the feature extraction.

146
00:10:45,170 --> 00:10:49,370
We could get the other parts which make up the model like this.

147
00:10:49,370 --> 00:10:51,710
Flatten the dance and the batch.

148
00:10:51,710 --> 00:10:52,460
Norm.

149
00:10:52,490 --> 00:10:54,530
So let's take this here.

150
00:10:55,610 --> 00:10:56,510
There we go.

151
00:10:56,750 --> 00:11:00,530
We are in this model, and let's just copy it.

152
00:11:00,530 --> 00:11:02,230
Let's paste it out here.

153
00:11:02,240 --> 00:11:09,680
So here we're going to have this also note that we're going to have feature or let's say low net.

154
00:11:09,890 --> 00:11:12,170
This is all the net model.

155
00:11:12,980 --> 00:11:13,910
Modify this.

156
00:11:13,910 --> 00:11:18,290
Here we have little net model, the net model.

157
00:11:18,290 --> 00:11:19,310
So that's fine.

158
00:11:19,460 --> 00:11:22,190
Now we've gotten this, everything is understood.

159
00:11:22,190 --> 00:11:28,130
We now check out this set of the flatten, equal flatten.

160
00:11:28,850 --> 00:11:34,370
And then next we have self dot dance one equal.

161
00:11:34,400 --> 00:11:36,920
Let's copy this out from here simply.

162
00:11:36,920 --> 00:11:41,750
So we have this dense right here, which is our dense one.

163
00:11:43,400 --> 00:11:44,360
There we go.

164
00:11:46,160 --> 00:11:56,210
We have our dense and then we have self dot batch one, which is all batch normalization.

165
00:11:57,260 --> 00:11:58,280
There we go.

166
00:11:58,880 --> 00:12:00,620
Copy this and paste.

167
00:12:01,910 --> 00:12:04,850
We move to dense two and batch two.

168
00:12:04,850 --> 00:12:06,520
So here we have dense two.

169
00:12:06,530 --> 00:12:07,910
We have batch two.

170
00:12:08,450 --> 00:12:09,860
This is ten actually.

171
00:12:09,860 --> 00:12:10,910
So we have that.

172
00:12:10,910 --> 00:12:13,730
And then finally we have this dense layer.

173
00:12:13,850 --> 00:12:15,410
So let's take this off.

174
00:12:15,410 --> 00:12:16,880
We have the dense layer.

175
00:12:17,500 --> 00:12:21,620
I'll put one activation sigmoid.

176
00:12:21,620 --> 00:12:22,640
So that's it.

177
00:12:23,390 --> 00:12:24,860
We call this dense three.

178
00:12:25,280 --> 00:12:26,180
So that's fine.

179
00:12:26,180 --> 00:12:28,190
Everything seems okay.

180
00:12:28,210 --> 00:12:29,900
Let's take this off now.

181
00:12:30,050 --> 00:12:32,030
And then there we go.

182
00:12:32,030 --> 00:12:33,820
We get into our call method.

183
00:12:33,830 --> 00:12:40,940
So yeah, we get into this call method and this call method will basically call all this different layers.

184
00:12:40,940 --> 00:12:48,770
So after the feature extraction, notice how we've created this class and this class makes use of this

185
00:12:48,770 --> 00:12:54,880
feature extractor, which was also created using the same models of class and method.

186
00:12:54,890 --> 00:12:55,790
So there we go.

187
00:12:55,790 --> 00:12:59,960
We're using this here and we actually using it here.

188
00:12:59,960 --> 00:13:00,740
So that's it.

189
00:13:01,970 --> 00:13:15,140
Now we just make this course so we have x equal self flatten and then we pass x x equal self.

190
00:13:15,140 --> 00:13:20,540
The dense one person x x

191
00:13:24,020 --> 00:13:29,510
x equals self dot batch one person.

192
00:13:29,960 --> 00:13:32,030
And then finally we have this.

193
00:13:32,330 --> 00:13:33,350
So there we go.

194
00:13:33,350 --> 00:13:37,280
We now return X just as we did previously, and we have our model.

195
00:13:37,280 --> 00:13:50,480
So here we have our Loonette, Loonette model, Loonette subclass model and we have this Loonette here,

196
00:13:51,050 --> 00:13:52,280
Loonette model.

197
00:13:52,520 --> 00:13:55,460
So let's take this off and there we go.

198
00:13:55,940 --> 00:14:05,120
We've just built our model, which when we try to find a summary, so we try to do Loonette subclass

199
00:14:05,120 --> 00:14:08,480
that summary, what do we obtain?

200
00:14:10,550 --> 00:14:13,880
You see, we this model has not yet been built.

201
00:14:13,910 --> 00:14:18,100
Build a model first by calling, build or by calling the model on a batch of data.

202
00:14:18,110 --> 00:14:21,020
So we're going to call this model on a batch of data.

203
00:14:21,620 --> 00:14:27,530
Yeah, we're going to have a little net subclass and then we have two zeros.

204
00:14:27,800 --> 00:14:35,470
So you have the zeros and one, two, two, 4 to 2, four and three.

205
00:14:35,480 --> 00:14:38,000
So let's run this and see what we get.

206
00:14:38,480 --> 00:14:39,200
That's fine.

207
00:14:39,200 --> 00:14:44,390
So yeah, we have our summary and then we are ready to compile this model.

208
00:14:45,230 --> 00:14:49,850
Yeah, we have the net net subclass.

209
00:14:49,850 --> 00:14:57,800
So we compile the net subclass and then we're going to fit the net subclass Loonette subclass.

210
00:14:57,800 --> 00:14:58,970
So we fit that.

211
00:14:59,400 --> 00:15:00,870
And everything shall work.

212
00:15:00,870 --> 00:15:01,200
Fine.

213
00:15:01,230 --> 00:15:03,210
Let's take this to just five epochs.

214
00:15:04,630 --> 00:15:09,550
We can see that we're getting similar results when we compare this with what we have with the functional

215
00:15:09,550 --> 00:15:12,060
API and the sequential API.

216
00:15:12,070 --> 00:15:15,820
So we now move on to creating custom layers.
