1
00:00:00,000 --> 00:00:03,000
So guys, now we are going to continue our discussion with respect to this particular project.

2
00:00:03,000 --> 00:00:07,000
Now already in our previous video we have actually created three pickle file.

3
00:00:07,000 --> 00:00:12,000
One is the scalar pickle file label encoder gender pickle file and one hot encoder for geography pickle

4
00:00:12,000 --> 00:00:13,000
file.

5
00:00:13,000 --> 00:00:16,000
Right now we will go ahead and train an artificial neural network.

6
00:00:16,000 --> 00:00:20,000
And that is what we are going to see how we are going to train this and all.

7
00:00:20,000 --> 00:00:22,000
We'll be discussing about that okay.

8
00:00:23,000 --> 00:00:27,000
So first of all we will go ahead and import TensorFlow okay.

9
00:00:27,000 --> 00:00:30,000
Since we are going to just use TensorFlow as tf okay.

10
00:00:30,000 --> 00:00:33,000
So tf is an alias which we will be specifically using.

11
00:00:33,000 --> 00:00:40,000
Now, uh, before I go ahead, let me just give you a brief idea, like how does a neural network basically

12
00:00:40,000 --> 00:00:42,000
gets created with the help of TensorFlow Keras?

13
00:00:42,000 --> 00:00:43,000
Okay.

14
00:00:43,000 --> 00:00:52,000
So as I said, uh, with respect to Ann, right now in Ann you have a input layer.

15
00:00:52,000 --> 00:00:54,000
Then you have a hidden layer.

16
00:00:54,000 --> 00:01:00,000
You can have multiple layers like hidden layer, like you can have HL one XL two, any number of hidden

17
00:01:00,000 --> 00:01:01,000
layers.

18
00:01:01,000 --> 00:01:01,000
Right.

19
00:01:01,000 --> 00:01:07,000
But just to give you a basic idea, basic Ann looks like it will be having one input layer.

20
00:01:07,000 --> 00:01:10,000
It can have one hidden layer, two hidden layers.

21
00:01:10,000 --> 00:01:12,000
And finally it has a output layer.

22
00:01:12,000 --> 00:01:12,000
Okay.

23
00:01:13,000 --> 00:01:22,000
When we probably take this entire neural network like a specific Ann, let's say in this input I have

24
00:01:22,000 --> 00:01:27,000
like this hidden layer, I have some three nodes, one more hidden layer, I have two nodes.

25
00:01:27,000 --> 00:01:28,000
And finally I have one output node.

26
00:01:29,000 --> 00:01:29,000
Right.

27
00:01:29,000 --> 00:01:35,000
This neural network here we are going to perform the forward propagation and backward propagation.

28
00:01:35,000 --> 00:01:43,000
So in TensorFlow we basically call it as a sequential sequential model.

29
00:01:43,000 --> 00:01:43,000
Okay.

30
00:01:43,000 --> 00:01:45,000
What do we call an As?

31
00:01:45,000 --> 00:01:48,000
It is nothing, but it is a sequential model, right.

32
00:01:48,000 --> 00:01:56,000
And this sequential model here you will be able to see that we will be doing forward propagation, we

33
00:01:56,000 --> 00:01:57,000
will be doing backward propagation.

34
00:01:57,000 --> 00:02:00,000
And all these nodes will be interconnected.

35
00:02:00,000 --> 00:02:00,000
Right.

36
00:02:00,000 --> 00:02:03,000
This input will be interconnected to this.

37
00:02:03,000 --> 00:02:05,000
Then this will be interconnected to this.

38
00:02:06,000 --> 00:02:08,000
And similarly this will be interconnected to this.

39
00:02:09,000 --> 00:02:11,000
This will be interconnected to this.

40
00:02:11,000 --> 00:02:11,000
Right.

41
00:02:12,000 --> 00:02:13,000
And this will also be interconnected.

42
00:02:13,000 --> 00:02:16,000
And finally you'll be interconnected to the output.

43
00:02:16,000 --> 00:02:17,000
So this is my input.

44
00:02:17,000 --> 00:02:18,000
This is my hidden layer one.

45
00:02:18,000 --> 00:02:20,000
This is my hidden layer two.

46
00:02:20,000 --> 00:02:24,000
All this interconnected lines that you have are nothing.

47
00:02:24,000 --> 00:02:31,000
But these are weights W1W2W3 like W4W5W6.

48
00:02:31,000 --> 00:02:32,000
Like this right.

49
00:02:32,000 --> 00:02:37,000
Now in order to give you a brief idea since I have, let's consider this right.

50
00:02:37,000 --> 00:02:37,000
I have two inputs.

51
00:02:37,000 --> 00:02:42,000
I have three, three, uh, nodes, hidden nodes in this hidden layer.

52
00:02:42,000 --> 00:02:42,000
Right.

53
00:02:42,000 --> 00:02:47,000
So here the number of weights that will be it will be nothing but two cross three weights.

54
00:02:47,000 --> 00:02:48,000
Right.

55
00:02:48,000 --> 00:02:50,000
And two cross three is nothing but six weights.

56
00:02:50,000 --> 00:02:51,000
Why two cross three?

57
00:02:51,000 --> 00:02:52,000
It's very simple.

58
00:02:53,000 --> 00:02:58,000
Two inputs, and it is getting connected to three weights at three hidden, uh, neurons in the hidden

59
00:02:58,000 --> 00:02:58,000
layer.

60
00:02:58,000 --> 00:03:02,000
Right along with this here also you will be having a bias B one.

61
00:03:03,000 --> 00:03:05,000
You'll be adding bias b2 and b3.

62
00:03:05,000 --> 00:03:11,000
So along with this six weights they are three bias in this first hidden layer okay.

63
00:03:12,000 --> 00:03:17,000
In the second hidden layer, uh, again here you have three hidden layer, uh, three hidden neurons.

64
00:03:17,000 --> 00:03:19,000
This is getting connected to two hidden neurons.

65
00:03:19,000 --> 00:03:23,000
So over here, you'll be able to see that the weight matrix will be three cross two.

66
00:03:23,000 --> 00:03:23,000
Right.

67
00:03:23,000 --> 00:03:27,000
So again you will be having one more additional six weights.

68
00:03:27,000 --> 00:03:27,000
Right.

69
00:03:28,000 --> 00:03:31,000
And uh here also bias will be added.

70
00:03:31,000 --> 00:03:33,000
So this will be my before this will be my be five.

71
00:03:33,000 --> 00:03:36,000
So here six weights and two bias will be there.

72
00:03:36,000 --> 00:03:37,000
Okay.

73
00:03:38,000 --> 00:03:40,000
So this is with respect to the hidden layer one.

74
00:03:41,000 --> 00:03:42,000
Hidden layer one.

75
00:03:43,000 --> 00:03:44,000
Sorry, hidden layer two.

76
00:03:44,000 --> 00:03:46,000
And this is with respect to hidden layer one.

77
00:03:46,000 --> 00:03:51,000
And finally you have this output layer here also your weights will be connected.

78
00:03:51,000 --> 00:03:53,000
So here some weights will be there.

79
00:03:53,000 --> 00:03:56,000
So here also how many weights will be there.

80
00:03:56,000 --> 00:03:58,000
Two cross one which is two weights.

81
00:03:59,000 --> 00:04:00,000
Right.

82
00:04:00,000 --> 00:04:04,000
And uh here also one bias will get added.

83
00:04:04,000 --> 00:04:06,000
So one bias.

84
00:04:06,000 --> 00:04:11,000
And after this you can probably apply a sigmoid activation function if it is a classification.

85
00:04:12,000 --> 00:04:15,000
If it is a multi-class classification, you can apply softmax right.

86
00:04:15,000 --> 00:04:17,000
So total number of parameters that you see.

87
00:04:17,000 --> 00:04:18,000
Right.

88
00:04:18,000 --> 00:04:22,000
If I say how many trainable parameters are there.

89
00:04:23,000 --> 00:04:30,000
Trainable parameters are there in this neural network it is very simple.

90
00:04:30,000 --> 00:04:36,000
You just say, hey, six plus three, this is nine, then nine plus six, 15, 15 plus two, 17, 17

91
00:04:36,000 --> 00:04:39,000
plus two, 19, 19 plus one, 20.

92
00:04:39,000 --> 00:04:46,000
So with the help of 20 trainable parameters, we will be doing the forward propagation and backward

93
00:04:46,000 --> 00:04:46,000
propagation.

94
00:04:47,000 --> 00:04:54,000
Now similarly this input is basically defined by the number of inputs that we have in our CSV file or

95
00:04:54,000 --> 00:04:55,000
in our data set.

96
00:04:55,000 --> 00:04:55,000
Right.

97
00:04:56,000 --> 00:05:01,000
In our data set, how many inputs we have in data set, how many inputs we have.

98
00:05:01,000 --> 00:05:01,000
If we have two.

99
00:05:01,000 --> 00:05:02,000
So it will be two.

100
00:05:02,000 --> 00:05:04,000
If we have three, it will be three nodes, right.

101
00:05:04,000 --> 00:05:07,000
If we have four, 11, ten any number of nodes.

102
00:05:07,000 --> 00:05:13,000
So in this way only we will be going and created our Ann which is a sequential network.

103
00:05:13,000 --> 00:05:17,000
Sequential network basically means it will be interconnected, right.

104
00:05:17,000 --> 00:05:22,000
Now there is also one more important point if we really want to just create this hidden neurons.

105
00:05:22,000 --> 00:05:27,000
So in Keras there is a library which is called as dense okay.

106
00:05:27,000 --> 00:05:29,000
There is a class which is called as dense okay.

107
00:05:29,000 --> 00:05:34,000
So let me again repeat what are the key parameters that we will be specifically using.

108
00:05:34,000 --> 00:05:42,000
First, when we start creating our Ann we have to initialize a sequential network okay.

109
00:05:42,000 --> 00:05:44,000
See sequential network.

110
00:05:44,000 --> 00:05:48,000
The second thing is that whenever we need to create a hidden neuron.

111
00:05:48,000 --> 00:05:48,000
Right.

112
00:05:48,000 --> 00:05:50,000
Hidden neuron I'm not talking about hidden layer.

113
00:05:50,000 --> 00:05:55,000
If you need to create a hidden neuron we will specifically using dense okay.

114
00:05:55,000 --> 00:05:58,000
So if I say hey dense I want 64 nodes.

115
00:05:58,000 --> 00:06:03,000
So in that particular hidden layer I will be having 64 hidden neurons.

116
00:06:03,000 --> 00:06:04,000
Okay something like this.

117
00:06:05,000 --> 00:06:07,000
So we will be using dense okay.

118
00:06:07,000 --> 00:06:13,000
Along with this, uh, you know that in every node we apply an activation function, right.

119
00:06:13,000 --> 00:06:18,000
So here we will also be using activation function.

120
00:06:18,000 --> 00:06:21,000
The activation function can be sigmoid.

121
00:06:21,000 --> 00:06:24,000
It can be tan h right.

122
00:06:24,000 --> 00:06:26,000
It can be ReLU.

123
00:06:26,000 --> 00:06:29,000
It can be leaky ReLU right.

124
00:06:29,000 --> 00:06:30,000
It can be many.

125
00:06:30,000 --> 00:06:32,000
Any number of others, right?

126
00:06:33,000 --> 00:06:37,000
But always it is a good idea that in the hidden layer you try to use ReLU.

127
00:06:37,000 --> 00:06:42,000
In the output layer you can use sigmoid or softmax, which I've actually discussed about it.

128
00:06:42,000 --> 00:06:44,000
Now this is my third important parameter.

129
00:06:44,000 --> 00:06:49,000
The fourth parameter that we will be using is something called as optimizer.

130
00:06:50,000 --> 00:06:54,000
Now this optimizer can be any kind of optimizer that we have.

131
00:06:54,000 --> 00:06:56,000
I will show you how you can initialize this particular optimizer.

132
00:06:56,000 --> 00:07:06,000
Also, optimizer is uh, useful in back propagation because these are responsible in updating the weights.

133
00:07:07,000 --> 00:07:07,000
Okay.

134
00:07:07,000 --> 00:07:09,000
Updating the weights.

135
00:07:10,000 --> 00:07:11,000
Very important.

136
00:07:11,000 --> 00:07:12,000
Okay.

137
00:07:12,000 --> 00:07:17,000
And the fifth one that we are specifically going to use is nothing but our loss function.

138
00:07:17,000 --> 00:07:23,000
And our main aim is that what loss function will be using and based on this loss function will be having

139
00:07:23,000 --> 00:07:25,000
a gradient descent and all will try to reduce this.

140
00:07:25,000 --> 00:07:26,000
Okay.

141
00:07:26,000 --> 00:07:29,000
And the sixth and the final thing is something called as metrics.

142
00:07:29,000 --> 00:07:34,000
Usually in the classification problem your metrics is like accuracy.

143
00:07:34,000 --> 00:07:41,000
In our regression problem you have MSE mean squared error, mean absolute error and all are there okay.

144
00:07:42,000 --> 00:07:48,000
So all these things will try to implement and my training information also what I will do my entire

145
00:07:48,000 --> 00:07:54,000
training information I will store the logs in some folder okay.

146
00:07:55,000 --> 00:07:58,000
So that I will be able to use tensor board.

147
00:07:58,000 --> 00:08:06,000
And the main aim of the tensor board library is to display this logs in a way that we will be able to

148
00:08:06,000 --> 00:08:07,000
understand.

149
00:08:07,000 --> 00:08:10,000
Some visualization graphs will be used in order to display it.

150
00:08:10,000 --> 00:08:11,000
Okay.

151
00:08:11,000 --> 00:08:14,000
So these are the steps that we are going to first of all focus.

152
00:08:14,000 --> 00:08:18,000
We are going to just go ahead and create a sequential neural network.

153
00:08:18,000 --> 00:08:22,000
Whenever we really want to create any hidden neurons, this hidden neuron, this hidden neuron or even

154
00:08:22,000 --> 00:08:26,000
even in the input I will be specifically using dense.

155
00:08:26,000 --> 00:08:26,000
Okay.

156
00:08:26,000 --> 00:08:29,000
So all these things we are going to go ahead and uh discuss.

157
00:08:29,000 --> 00:08:35,000
So let me quickly, uh, open this now, I will go back to my code.

158
00:08:37,000 --> 00:08:37,000
Okay.

159
00:08:37,000 --> 00:08:43,000
And, uh, here you will be able to see that I will just go ahead and import TensorFlow okay.

160
00:08:44,000 --> 00:08:49,000
So I'm going to import TensorFlow as tf I told you I'm going to use sequential model.

161
00:08:49,000 --> 00:08:50,000
So how do I import it.

162
00:08:50,000 --> 00:08:59,000
So I will go ahead and say hey from TensorFlow from TensorFlow dot Keras dot models.

163
00:08:59,000 --> 00:09:03,000
We are going to import this sequential model.

164
00:09:05,000 --> 00:09:10,000
Sequential okay from TensorFlow Keras dot model okay.

165
00:09:11,000 --> 00:09:19,000
Similarly I will go ahead and write from TensorFlow dot keras dot.

166
00:09:19,000 --> 00:09:24,000
As I said you whenever I need to create a node it is nothing but using dense.

167
00:09:24,000 --> 00:09:29,000
Okay, dense will be that library that we will be using and this entire thing will be present inside

168
00:09:29,000 --> 00:09:30,000
layers.

169
00:09:30,000 --> 00:09:30,000
Okay.

170
00:09:30,000 --> 00:09:33,000
So I'm just going to import dense.

171
00:09:34,000 --> 00:09:35,000
So this is one more library.

172
00:09:35,000 --> 00:09:41,000
Along with this I will be showing you one very important property we'll discuss about which is called

173
00:09:41,000 --> 00:09:45,000
as TensorFlow Keras dot callbacks.

174
00:09:45,000 --> 00:09:46,000
Okay.

175
00:09:46,000 --> 00:09:50,000
And we're just going to import something called as early stopping.

176
00:09:50,000 --> 00:09:53,000
We'll discuss about this early stopping what exactly it is okay.

177
00:09:53,000 --> 00:09:57,000
And finally we have this tensor board okay.

178
00:09:58,000 --> 00:10:01,000
Now tensor board uh we have implemented this.

179
00:10:01,000 --> 00:10:05,000
And finally I'm also going to import date time because I'm going to use this date time also.

180
00:10:05,000 --> 00:10:09,000
So I have executed or imported all these libraries which we are going to use.

181
00:10:09,000 --> 00:10:14,000
One is sequential, one is dense, one is early stopping and one is TensorBoard.

182
00:10:14,000 --> 00:10:17,000
Okay, now let's go ahead and build our model.

183
00:10:18,000 --> 00:10:23,000
Build our an model okay.

184
00:10:25,000 --> 00:10:27,000
Now to build the an model.

185
00:10:27,000 --> 00:10:29,000
What all things we are specifically going to do.

186
00:10:29,000 --> 00:10:33,000
As I said I'm going to create first of all a sequential model.

187
00:10:33,000 --> 00:10:37,000
So I will go ahead and initialize and let me just go ahead and initialize sequential.

188
00:10:38,000 --> 00:10:38,000
Okay.

189
00:10:39,000 --> 00:10:43,000
Now inside the sequential it is important.

190
00:10:43,000 --> 00:10:44,000
Please try to understand this okay.

191
00:10:46,000 --> 00:10:51,000
Inside the sequential I am going to use some layers dense layers and all.

192
00:10:51,000 --> 00:10:52,000
Okay.

193
00:10:52,000 --> 00:10:57,000
So here uh uh if I go back to my diagram.

194
00:10:57,000 --> 00:10:59,000
Okay, let's go back to my diagram over here.

195
00:11:00,000 --> 00:11:08,000
First of all, let's go ahead and understand how many number of inputs that I have okay.

196
00:11:09,000 --> 00:11:14,000
So first this is my entire sequential model okay.

197
00:11:17,000 --> 00:11:19,000
This is my entire sequential model.

198
00:11:20,000 --> 00:11:24,000
Now inside the sequential model, how many inputs I need to probably consider.

199
00:11:24,000 --> 00:11:32,000
So if I go ahead and see my X train dot shape, and from this, if I just try to find out how many columns

200
00:11:32,000 --> 00:11:38,000
are there, that will actually help us to decide how many inputs will be there, right?

201
00:11:38,000 --> 00:11:39,000
How many inputs will be there?

202
00:11:39,000 --> 00:11:42,000
So I have to probably use this entire inputs.

203
00:11:42,000 --> 00:11:42,000
Okay.

204
00:11:42,000 --> 00:11:43,000
Over here.

205
00:11:43,000 --> 00:11:50,000
And let's say that I will be using the sequential and I'll say, hey, initially I'll take this 11 inputs

206
00:11:50,000 --> 00:11:53,000
and then I will go ahead and create my dense.

207
00:11:53,000 --> 00:11:56,000
I'll use this dense library and create my hidden layer.

208
00:11:56,000 --> 00:12:00,000
Let's say that I'm going to use 64 nodes, any number of nodes in this hidden layer.

209
00:12:00,000 --> 00:12:01,000
Right.

210
00:12:01,000 --> 00:12:07,000
And when I am creating this dense, I will also give my input shape, like how many elements are coming

211
00:12:07,000 --> 00:12:08,000
from this input data.

212
00:12:08,000 --> 00:12:13,000
So let's say from this I, I'm getting this x train dot shape of one.

213
00:12:13,000 --> 00:12:19,000
If I go ahead and write like this, it says that what is the input that is probably coming from my X

214
00:12:19,000 --> 00:12:19,000
train data.

215
00:12:19,000 --> 00:12:21,000
That input will get connected over here.

216
00:12:22,000 --> 00:12:22,000
Okay.

217
00:12:22,000 --> 00:12:26,000
So we are initializing our input over here along with the dense layer.

218
00:12:26,000 --> 00:12:28,000
So this is what we are going to first of all do okay.

219
00:12:28,000 --> 00:12:35,000
So quickly I'll go back over here and now see focus on this okay I need to give my input and my hidden

220
00:12:35,000 --> 00:12:35,000
layer one.

221
00:12:35,000 --> 00:12:40,000
First I'll use this dense, let's say in my hidden layer what I'm going to say hey, we are just going

222
00:12:40,000 --> 00:12:42,000
to use 64 neurons.

223
00:12:42,000 --> 00:12:43,000
I'm just considering.

224
00:12:43,000 --> 00:12:45,000
Hey let's go ahead and use 64 neurons.

225
00:12:45,000 --> 00:12:48,000
Now in all this neuron I also need to apply an activation function.

226
00:12:48,000 --> 00:12:53,000
So I will go ahead and apply an activation function okay.

227
00:12:53,000 --> 00:12:58,000
Now once I apply the activation function I will just go ahead and apply ReLU activation function.

228
00:12:58,000 --> 00:12:59,000
Okay.

229
00:12:59,000 --> 00:13:04,000
It is up to you whatever activation functions that you really want to apply now to this hidden layer,

230
00:13:04,000 --> 00:13:06,000
what will be the input that will be coming.

231
00:13:06,000 --> 00:13:11,000
So here you will be having this particular parameter which is called as input underscore shape.

232
00:13:11,000 --> 00:13:15,000
And this is only for the first hidden layer that you really need to write, because it is getting connected

233
00:13:15,000 --> 00:13:18,000
to some inputs over there, right in the second hidden layer and all.

234
00:13:18,000 --> 00:13:23,000
We don't need to write this input underscore shape, but always for the first hidden layer we need to

235
00:13:23,000 --> 00:13:23,000
write this.

236
00:13:23,000 --> 00:13:26,000
So my input underscore shape will be nothing.

237
00:13:26,000 --> 00:13:30,000
But it will uh, again just go ahead and write something like this.

238
00:13:30,000 --> 00:13:31,000
Right.

239
00:13:31,000 --> 00:13:37,000
So it will be x underscore train dot shape.

240
00:13:37,000 --> 00:13:43,000
Because this shape of one, if I probably consider it is just going to take that particular value.

241
00:13:43,000 --> 00:13:47,000
And it is going to consider that that many number of inputs are there.

242
00:13:47,000 --> 00:13:57,000
So if I just go ahead and execute this over here, what is my X underscore train dot shape of one okay

243
00:13:57,000 --> 00:13:59,000
I'll be okay.

244
00:13:59,000 --> 00:13:59,000
Tuple.

245
00:13:59,000 --> 00:14:02,000
Uh so here it says okay I have to use this.

246
00:14:03,000 --> 00:14:06,000
Uh I have to use this index okay.

247
00:14:07,000 --> 00:14:09,000
So shape of one.

248
00:14:11,000 --> 00:14:12,000
Okay.

249
00:14:12,000 --> 00:14:15,000
So here you can see that there are two L elements okay.

250
00:14:15,000 --> 00:14:18,000
In my X underscore train dot shape of one.

251
00:14:18,000 --> 00:14:24,000
Right now if I'm giving input underscore shape of this value comma blank.

252
00:14:24,000 --> 00:14:28,000
If I just give comma blank like this in a tuple.

253
00:14:29,000 --> 00:14:34,000
So I'm just saying that hey it is a single dimension and it has 12 inputs okay.

254
00:14:34,000 --> 00:14:37,000
And that is how I'm also giving over here as my input shape.

255
00:14:37,000 --> 00:14:38,000
Clear.

256
00:14:38,000 --> 00:14:39,000
Very much simple.

257
00:14:39,000 --> 00:14:41,000
Now this is my first hidden layer.

258
00:14:41,000 --> 00:14:43,000
So I'll write down the comment over here.

259
00:14:43,000 --> 00:14:43,000
First hidden layer.

260
00:14:44,000 --> 00:14:48,000
Uh and it is in uh connected with input layer.

261
00:14:48,000 --> 00:14:49,000
Okay.

262
00:14:49,000 --> 00:14:51,000
Connected with input layer.

263
00:14:51,000 --> 00:14:53,000
This is perfect okay.

264
00:14:53,000 --> 00:15:00,000
Now in my second layer again let's go ahead and use the dense I will use 32 neurons over here.

265
00:15:00,000 --> 00:15:03,000
And I have to just go ahead and apply my activation function.

266
00:15:03,000 --> 00:15:08,000
Now after I apply my activation function, I don't even have to give any input shape over here, because

267
00:15:08,000 --> 00:15:13,000
now we know since we have used sequential, it knows that it will be connected, right?

268
00:15:13,000 --> 00:15:15,000
All these layers will be specifically connected.

269
00:15:15,000 --> 00:15:15,000
Okay.

270
00:15:15,000 --> 00:15:21,000
Now finally you will be also see that I'll go ahead and apply one dense one okay.

271
00:15:21,000 --> 00:15:25,000
And then I will say hey go ahead and apply another activation function.

272
00:15:25,000 --> 00:15:32,000
And the reason I'm saying that another activation function, this is my hidden layer two HL two okay.

273
00:15:32,000 --> 00:15:36,000
And here you will be able to see that this is nothing.

274
00:15:36,000 --> 00:15:37,000
But this is my output layer.

275
00:15:38,000 --> 00:15:39,000
Output layer.

276
00:15:39,000 --> 00:15:40,000
How many outputs I need to find out?

277
00:15:40,000 --> 00:15:41,000
Only one.

278
00:15:41,000 --> 00:15:41,000
Right.

279
00:15:41,000 --> 00:15:42,000
It is a binary output.

280
00:15:42,000 --> 00:15:43,000
Right.

281
00:15:43,000 --> 00:15:47,000
So I'll say hey let's go ahead and use this sigmoid over here Okay.

282
00:15:47,000 --> 00:15:51,000
So once I execute this so this actually becomes my entire model.

283
00:15:52,000 --> 00:15:52,000
Okay.

284
00:15:52,000 --> 00:15:54,000
My entire model over here okay.

285
00:15:54,000 --> 00:15:57,000
So if I go ahead and execute this this is my entire model.

286
00:15:58,000 --> 00:16:04,000
Very simple I guess right now just imagine how many parameters will be there.

287
00:16:04,000 --> 00:16:08,000
So what I've actually done over here, let me just go ahead and talk about it okay.

288
00:16:09,000 --> 00:16:13,000
So here I've created a input layer.

289
00:16:13,000 --> 00:16:15,000
So this is my input layer.

290
00:16:15,000 --> 00:16:21,000
This input layer has uh inputs of 12 inputs.

291
00:16:21,000 --> 00:16:22,000
Right.

292
00:16:22,000 --> 00:16:23,000
12 inputs 12 comma some.

293
00:16:23,000 --> 00:16:24,000
Let's consider 12.

294
00:16:24,000 --> 00:16:27,000
Then I have a hidden layer.

295
00:16:27,000 --> 00:16:33,000
This hidden layer is basically happening having 64 hidden neurons.

296
00:16:33,000 --> 00:16:36,000
Right 64 hidden neurons.

297
00:16:36,000 --> 00:16:38,000
Then I have one more hidden layer.

298
00:16:40,000 --> 00:16:43,000
Which has 32 hidden neurons.

299
00:16:43,000 --> 00:16:48,000
And finally, this is my output layer, which is having one output, right?

300
00:16:48,000 --> 00:16:49,000
One neuron.

301
00:16:49,000 --> 00:16:50,000
And this all will be interconnected.

302
00:16:50,000 --> 00:16:52,000
And this is what we have actually created.

303
00:16:52,000 --> 00:16:52,000
Right.

304
00:16:52,000 --> 00:16:56,000
And now we have to probably do the forward and backward propagation.

305
00:16:58,000 --> 00:17:00,000
Now let me just go back to the code.

306
00:17:00,000 --> 00:17:02,000
Now let's go ahead and write model dot summary.

307
00:17:02,000 --> 00:17:06,000
And with the help of model dot summary you'll be able to see that I'll be able to see how many total

308
00:17:06,000 --> 00:17:07,000
number of parameters are there.

309
00:17:07,000 --> 00:17:11,000
So they are around 2945 parameters.

310
00:17:11,000 --> 00:17:12,000
Okay.

311
00:17:12,000 --> 00:17:17,000
So here uh, you can probably see in my dense, uh, initially you have the 64.

312
00:17:18,000 --> 00:17:21,000
Um, then you have this 32, then you have this one.

313
00:17:21,000 --> 00:17:21,000
Okay.

314
00:17:22,000 --> 00:17:22,000
Parameters.

315
00:17:22,000 --> 00:17:26,000
This is nothing, but it is a combination of all the weights and bias.

316
00:17:26,000 --> 00:17:30,000
And that is the reason the total number of parameters will be two nine, four, five okay.

317
00:17:30,000 --> 00:17:32,000
So this is the entire model.

318
00:17:32,000 --> 00:17:35,000
And I'm actually going to do the forward and backward propagation with respect to this.

319
00:17:35,000 --> 00:17:39,000
Now in order to do the forward and backward propagation we need to compile this model.

320
00:17:39,000 --> 00:17:43,000
So let me just go ahead and write compile the model okay.

321
00:17:43,000 --> 00:17:47,000
Now with respect to the compile the model I'll just go ahead and write model dot compile.

322
00:17:48,000 --> 00:17:50,000
And here I'm just going to use some parameters.

323
00:17:50,000 --> 00:17:52,000
One is optimizer.

324
00:17:52,000 --> 00:17:53,000
Okay.

325
00:17:53,000 --> 00:17:57,000
Right now let's keep it blank I will initialize some optimizer over here.

326
00:17:57,000 --> 00:17:59,000
Then you have loss.

327
00:17:59,000 --> 00:18:04,000
And this loss uh I'm just going to use binary cross entropy.

328
00:18:04,000 --> 00:18:07,000
If it is a multi classification you can use sparse cross entropy okay.

329
00:18:07,000 --> 00:18:11,000
So there is a different different values with respect to multi classification.

330
00:18:11,000 --> 00:18:15,000
You will be seeing a parameter which is called as sparse cross entropy.

331
00:18:15,000 --> 00:18:17,000
Again you can go ahead and check with respect to Keras API.

332
00:18:18,000 --> 00:18:21,000
And here we will also go ahead and use one matrix parameter.

333
00:18:21,000 --> 00:18:24,000
And this will be nothing but it will be accuracy.

334
00:18:25,000 --> 00:18:28,000
It is given in the form of list because you can add multiple values also.

335
00:18:29,000 --> 00:18:33,000
Now uh, quickly, one more thing that I really want to show that over here.

336
00:18:33,000 --> 00:18:40,000
Uh, is this the only way to probably put any values, or can I probably go ahead and use some other

337
00:18:40,000 --> 00:18:42,000
way of applying optimizers and all?

338
00:18:42,000 --> 00:18:45,000
Okay, so, uh, let me just show you one more way.

339
00:18:45,000 --> 00:18:46,000
Okay.

340
00:18:46,000 --> 00:18:53,000
So here I'll say, uh, Opt optimizer is nothing but TensorFlow dot.

341
00:18:53,000 --> 00:18:53,000
Okay.

342
00:18:53,000 --> 00:18:56,000
There is a function which is called as optimizers.

343
00:18:57,000 --> 00:19:00,000
TensorFlow optimizers.

344
00:19:00,000 --> 00:19:01,000
Okay.

345
00:19:01,000 --> 00:19:01,000
Sorry.

346
00:19:01,000 --> 00:19:02,000
TensorFlow.

347
00:19:02,000 --> 00:19:05,000
Keras dot Keras dot optimizer.

348
00:19:06,000 --> 00:19:06,000
Okay.

349
00:19:06,000 --> 00:19:10,000
And here we have something called as Adam optimizer.

350
00:19:12,000 --> 00:19:14,000
I think so it should be working fine.

351
00:19:14,000 --> 00:19:22,000
And let's use my learning underscore rate is equal to 0.01.

352
00:19:23,000 --> 00:19:23,000
Okay.

353
00:19:24,000 --> 00:19:24,000
or okay.

354
00:19:24,000 --> 00:19:26,000
TensorFlow is not defined.

355
00:19:26,000 --> 00:19:28,000
So that is the reason you could not see it okay.

356
00:19:29,000 --> 00:19:30,000
Okay.

357
00:19:30,000 --> 00:19:36,000
So now what we have actually done is that see over here when we go ahead and give one optimizer, let's

358
00:19:36,000 --> 00:19:39,000
say that I want to go ahead and give one optimizer over here.

359
00:19:39,000 --> 00:19:41,000
And the optimizer name is Adam okay.

360
00:19:41,000 --> 00:19:45,000
This is the keyword that we can specifically use again in Keras API documentation.

361
00:19:45,000 --> 00:19:48,000
If you go and see I'm actually applying Adam over here.

362
00:19:48,000 --> 00:19:49,000
Okay.

363
00:19:49,000 --> 00:19:52,000
But this Adam has a fixed learning rate okay.

364
00:19:52,000 --> 00:19:53,000
Over here it has a learning rate.

365
00:19:53,000 --> 00:19:56,000
But you you need to provide your own learning rate.

366
00:19:56,000 --> 00:20:01,000
So what you can do you can just import TensorFlow and you can write hey TensorFlow keras dot optimizer

367
00:20:01,000 --> 00:20:03,000
Adam and not any Adam.

368
00:20:03,000 --> 00:20:05,000
See there are a lot of other optimizers.

369
00:20:05,000 --> 00:20:06,000
Also, let me just show you.

370
00:20:06,000 --> 00:20:09,000
So here I'll go ahead and write optimizers.

371
00:20:11,000 --> 00:20:13,000
Dot Adam.

372
00:20:13,000 --> 00:20:16,000
So instead of using Adam you have adadelta add a factor.

373
00:20:16,000 --> 00:20:17,000
Adagrad Adam, Adam w Adam.

374
00:20:17,000 --> 00:20:21,000
Max I think, uh, most of them I have already discussed.

375
00:20:21,000 --> 00:20:24,000
We have discussed Adam, we have discussed adadelta all these things.

376
00:20:24,000 --> 00:20:25,000
Right?

377
00:20:25,000 --> 00:20:25,000
Adagrad.

378
00:20:25,000 --> 00:20:26,000
Also, we have discussed.

379
00:20:26,000 --> 00:20:27,000
Right.

380
00:20:27,000 --> 00:20:30,000
So let's consider right now we'll just go ahead and use Adam.

381
00:20:30,000 --> 00:20:34,000
And here, uh, there will be a parameter which is called as the learning rate, which we can actually

382
00:20:34,000 --> 00:20:35,000
define.

383
00:20:35,000 --> 00:20:35,000
Okay.

384
00:20:36,000 --> 00:20:38,000
So here I have actually defined 0.01.

385
00:20:38,000 --> 00:20:43,000
Similarly, what you can do is that you can also go ahead and write TensorFlow dot Keras.

386
00:20:43,000 --> 00:20:56,000
And you can also set your uh loss okay losses and uh dot different different losses will be also there

387
00:20:56,000 --> 00:20:57,000
I guess.

388
00:20:57,000 --> 00:21:02,000
Let's see uh see over here you have are binary cross entropy.

389
00:21:02,000 --> 00:21:04,000
Then you have categorical cross entropy.

390
00:21:04,000 --> 00:21:06,000
You can use all these specific losses if you want.

391
00:21:06,000 --> 00:21:10,000
Let's say if I want to directly use binary cross entropy I can also use this okay.

392
00:21:10,000 --> 00:21:14,000
And I can store this in one variable like one loss.

393
00:21:14,000 --> 00:21:16,000
And I can use this particular loss over here.

394
00:21:16,000 --> 00:21:19,000
Like see if I use this opt I'll be using this over here.

395
00:21:19,000 --> 00:21:20,000
Copy and paste it.

396
00:21:20,000 --> 00:21:21,000
Right.

397
00:21:21,000 --> 00:21:23,000
So I'm showing you both the ways how you can actually do it directly.

398
00:21:23,000 --> 00:21:28,000
You can also use this particular keyword, or you can also go ahead and initialize this okay.

399
00:21:28,000 --> 00:21:32,000
So if I go ahead and initialize this so I will be able to see that hey this is my loss which looks like

400
00:21:32,000 --> 00:21:33,000
right.

401
00:21:33,000 --> 00:21:35,000
But uh both these ways.

402
00:21:35,000 --> 00:21:38,000
So what I'll do I'll take this optimizer, I'll put it over here.

403
00:21:38,000 --> 00:21:42,000
And similarly I'll use this particular loss and we'll go ahead and do the compilation.

404
00:21:42,000 --> 00:21:42,000
Okay.

405
00:21:43,000 --> 00:21:46,000
Now when we are doing the compilation this is the compiling the model over here.

406
00:21:46,000 --> 00:21:47,000
So okay.

407
00:21:47,000 --> 00:21:50,000
Uh, there is an error metric.

408
00:21:50,000 --> 00:21:52,000
Uh, please.

409
00:21:52,000 --> 00:21:54,000
Uh, okay, let's see what it says.

410
00:21:54,000 --> 00:22:01,000
Including this, this this this this this metric metric metric metrics.

411
00:22:01,000 --> 00:22:03,000
It should be, uh, something like metrics.

412
00:22:03,000 --> 00:22:03,000
Okay.

413
00:22:03,000 --> 00:22:05,000
So this is the keyword that is used.

414
00:22:05,000 --> 00:22:07,000
So uh, again this kind of error will come.

415
00:22:07,000 --> 00:22:10,000
I'm making sure that I don't delete any of the error okay.

416
00:22:11,000 --> 00:22:17,000
Now the next thing what I will do I will go ahead and set up the TensorBoard because we have still not

417
00:22:17,000 --> 00:22:18,000
started the training.

418
00:22:18,000 --> 00:22:19,000
Right?

419
00:22:19,000 --> 00:22:20,000
We have still not started.

420
00:22:20,000 --> 00:22:25,000
The training and training will be set up, you know, as soon as I probably start training.

421
00:22:25,000 --> 00:22:26,000
Uh, sorry.

422
00:22:26,000 --> 00:22:27,000
This.

423
00:22:27,000 --> 00:22:32,000
Once the training gets completed, we will also be able to, uh, capture that logs and we'll be able

424
00:22:32,000 --> 00:22:33,000
to visualize that logs.

425
00:22:33,000 --> 00:22:35,000
So that is the reason we set up this TensorBoard.

426
00:22:35,000 --> 00:22:39,000
So I'll create a directory which is called as log underscore directory.

427
00:22:39,000 --> 00:22:42,000
And here I will say hey make this folder okay.

428
00:22:42,000 --> 00:22:48,000
So first of all log slash fit I will probably make this folder over here okay.

429
00:22:49,000 --> 00:22:54,000
And I'll say hey go ahead and make this and use some date time.

430
00:22:54,000 --> 00:22:58,000
Use some date time format so that you'll be able to see this.

431
00:22:58,000 --> 00:23:03,000
And then I will go ahead and write date time okay Dot now.

432
00:23:03,000 --> 00:23:04,000
Okay.

433
00:23:04,000 --> 00:23:05,000
I'm using this date time.

434
00:23:05,000 --> 00:23:08,000
And you let me use some time format.

435
00:23:08,000 --> 00:23:11,000
So I will go ahead and write str of time.

436
00:23:11,000 --> 00:23:15,000
And I will just use this particular time format to capture my logs.

437
00:23:15,000 --> 00:23:15,000
Okay.

438
00:23:15,000 --> 00:23:18,000
So let me just copy and paste it over here okay.

439
00:23:18,000 --> 00:23:21,000
So this is my time format that I'm actually going to use okay.

440
00:23:22,000 --> 00:23:26,000
It will basically go ahead and create this entire directory in shot.

441
00:23:26,000 --> 00:23:26,000
Okay.

442
00:23:27,000 --> 00:23:32,000
Now, uh, quickly, uh, let's do one more, uh, thing over here.

443
00:23:32,000 --> 00:23:36,000
Is that, uh, I'm also going to, uh, uh, okay.

444
00:23:36,000 --> 00:23:39,000
For right now, let me just go ahead and create this logs directory.

445
00:23:39,000 --> 00:23:45,000
And, uh, it is going to make sure that whenever we train our model, it will go ahead and it will

446
00:23:45,000 --> 00:23:46,000
store all the logs over here.

447
00:23:46,000 --> 00:23:47,000
Okay.

448
00:23:48,000 --> 00:23:49,000
Perfect.

449
00:23:49,000 --> 00:23:50,000
Uh, till here.

450
00:23:50,000 --> 00:23:52,000
I think everybody is, uh, good enough.

451
00:23:52,000 --> 00:23:55,000
Uh, now, uh, let me do one more thing.

452
00:23:55,000 --> 00:24:00,000
Let me just go ahead and create my TensorFlow callback.

453
00:24:00,000 --> 00:24:00,000
Okay.

454
00:24:00,000 --> 00:24:03,000
So I'm going to probably create this particular variable.

455
00:24:03,000 --> 00:24:05,000
And what is the main aim of this.

456
00:24:05,000 --> 00:24:08,000
We will just go ahead and say hey use this TensorBoard.

457
00:24:08,000 --> 00:24:10,000
What we are trying to import.

458
00:24:10,000 --> 00:24:13,000
Now this TensorBoard we need to import it okay.

459
00:24:13,000 --> 00:24:16,000
So in order to import it I will be importing two libraries.

460
00:24:16,000 --> 00:24:18,000
Since I'm going to import two important things.

461
00:24:18,000 --> 00:24:26,000
One is import tensorflow dot Keras dot calls back okay I'll be talking about what is the importance

462
00:24:26,000 --> 00:24:26,000
of this.

463
00:24:26,000 --> 00:24:28,000
Calls back just in some time.

464
00:24:28,000 --> 00:24:34,000
So I'll go ahead and write hey import early stopping along with this I'm just going to import TensorBoard.

465
00:24:34,000 --> 00:24:36,000
I will talk about both, uh, early stopping and TensorBoard.

466
00:24:36,000 --> 00:24:43,000
But right now you just understand that tensor board is just to visualize all your logs that you have

467
00:24:43,000 --> 00:24:44,000
while training your entire model.

468
00:24:44,000 --> 00:24:45,000
Okay.

469
00:24:45,000 --> 00:24:47,000
You can also do it manually with the help of matplotlib.

470
00:24:47,000 --> 00:24:50,000
But I feel tensor board will be a good one.

471
00:24:50,000 --> 00:24:52,000
Okay, so here I have initialized tensor board.

472
00:24:52,000 --> 00:24:56,000
I'm saying hey, let's give this as my log directory over here.

473
00:24:56,000 --> 00:24:57,000
Log directory is equal to.

474
00:24:57,000 --> 00:25:01,000
I'm just going to give my log directory whichever log directory I've actually created.

475
00:25:01,000 --> 00:25:07,000
The next thing that I will be using is some histogram frequency as one.

476
00:25:07,000 --> 00:25:12,000
To just see that some of the histogram diagrams is also created from here.

477
00:25:12,000 --> 00:25:12,000
Okay.

478
00:25:13,000 --> 00:25:16,000
So once this is done I'll go ahead and execute it.

479
00:25:16,000 --> 00:25:17,000
Invalid syntax.

480
00:25:18,000 --> 00:25:19,000
Okay.

481
00:25:21,000 --> 00:25:24,000
Uh from I have to use over here as from.

482
00:25:25,000 --> 00:25:25,000
Okay.

483
00:25:25,000 --> 00:25:26,000
So perfect.

484
00:25:27,000 --> 00:25:29,000
This works absolutely fine.

485
00:25:29,000 --> 00:25:29,000
Okay.

486
00:25:29,000 --> 00:25:36,000
Now we will also go ahead and set up something called as early stopping.

487
00:25:36,000 --> 00:25:38,000
Now why exactly is this early stopping?

488
00:25:38,000 --> 00:25:43,000
See guys, when we are training a neural network we can train it for any number of epochs.

489
00:25:43,000 --> 00:25:43,000
Okay.

490
00:25:44,000 --> 00:25:46,000
We can train it for multiple epochs.

491
00:25:46,000 --> 00:25:47,000
100 epochs.

492
00:25:47,000 --> 00:25:51,000
You know, we can create different different batch size and we can do forward and backward propagation.

493
00:25:51,000 --> 00:25:58,000
But, uh, you know, it may happen in such a way that even we run for 5 to 6 epochs continuously there.

494
00:25:58,000 --> 00:26:01,000
Let's say I'm trying it to run it for 100 epochs.

495
00:26:01,000 --> 00:26:01,000
Okay.

496
00:26:02,000 --> 00:26:10,000
But if we see such a scenario where in 20 epochs, only my model has trained at this batch level, and

497
00:26:10,000 --> 00:26:14,000
after that it is just varying by 1 or 2%, right?

498
00:26:14,000 --> 00:26:19,000
Then it is not necessary that you need to probably train that particular model for 100 epochs, right?

499
00:26:20,000 --> 00:26:24,000
Uh, whenever we train our model, we have to probably continuously monitor our loss value.

500
00:26:24,000 --> 00:26:26,000
If that loss value is decreasing, then it is fine.

501
00:26:26,000 --> 00:26:27,000
We can train it continuously.

502
00:26:27,000 --> 00:26:32,000
But let's say that after a certain number of epochs, that particular loss value is not decreasing.

503
00:26:32,000 --> 00:26:34,000
So what do we do at that point time.

504
00:26:34,000 --> 00:26:39,000
We don't need to probably run the entire 100 epochs since, uh, what we can do, we can say, hey,

505
00:26:39,000 --> 00:26:40,000
go ahead and apply this early.

506
00:26:40,000 --> 00:26:42,000
Stopping where?

507
00:26:42,000 --> 00:26:43,000
Go ahead and see only the loss value.

508
00:26:43,000 --> 00:26:49,000
If it is not decreasing, let's say for the five epochs itself, then you can stop the training there

509
00:26:49,000 --> 00:26:49,000
itself.

510
00:26:49,000 --> 00:26:52,000
So and that is the reason why we use early stopping.

511
00:26:52,000 --> 00:26:56,000
So here I'm just going to create my early stopping callback okay.

512
00:26:56,000 --> 00:26:58,000
So this is just like a callback that we use.

513
00:26:58,000 --> 00:27:02,000
And here uh we will go ahead and write early stopping.

514
00:27:02,000 --> 00:27:07,000
We will go ahead and monitor one very important parameter while we are training, right, which is called

515
00:27:07,000 --> 00:27:10,000
as validation loss val underscore loss.

516
00:27:10,000 --> 00:27:13,000
I will talk about what all keys is also getting created.

517
00:27:13,000 --> 00:27:14,000
Okay.

518
00:27:14,000 --> 00:27:16,000
Um like you'll be able to see multiple keys.

519
00:27:16,000 --> 00:27:18,000
Uh you'll have validation loss.

520
00:27:18,000 --> 00:27:19,000
You'll have training loss and all.

521
00:27:19,000 --> 00:27:22,000
But right now I'm just going to monitor this validation loss.

522
00:27:22,000 --> 00:27:27,000
And let's say I'm saying hey be patient for at least five epochs, okay.

523
00:27:27,000 --> 00:27:29,000
Before taking that particular decision.

524
00:27:29,000 --> 00:27:33,000
If till the five epochs you see there is no improvement, then you can stop it over there.

525
00:27:33,000 --> 00:27:33,000
Okay.

526
00:27:33,000 --> 00:27:38,000
And then one more parameter that I'm actually going to say hey, it should restore the best weights.

527
00:27:38,000 --> 00:27:43,000
So when you are, uh, going through the forward and the backward propagation which at which epoch,

528
00:27:43,000 --> 00:27:46,000
you find out the best weight, you can probably consider that.

529
00:27:46,000 --> 00:27:49,000
And you can reload it when you stop the early stopping.

530
00:27:49,000 --> 00:27:49,000
Okay.

531
00:27:49,000 --> 00:27:53,000
So I'm just going to use all these parameters and do the early stopping right.

532
00:27:53,000 --> 00:27:54,000
Very important.

533
00:27:54,000 --> 00:28:01,000
So this will be my early stopping that I'll use now finally now this is the stage of training the model

534
00:28:01,000 --> 00:28:08,000
okay I've created my step by step what I've actually done I have created my entire model.

535
00:28:08,000 --> 00:28:14,000
I have said, hey, which, uh, optimizes I'm going to use, which loss I'm going to use and I've,

536
00:28:15,000 --> 00:28:20,000
I've assigned that entire optimizer and loss to my model along with my metrics.

537
00:28:20,000 --> 00:28:20,000
Okay.

538
00:28:21,000 --> 00:28:24,000
Then I'm saying, hey, go ahead and set up the TensorBoard.

539
00:28:24,000 --> 00:28:28,000
Um, you have to probably create all the logs while training.

540
00:28:28,000 --> 00:28:30,000
So this is the logs.

541
00:28:30,000 --> 00:28:33,000
And from this particular logs only we will try to visualize some of the data.

542
00:28:33,000 --> 00:28:35,000
Now here I have created TensorFlow callback.

543
00:28:35,000 --> 00:28:37,000
And here I have actually created Earlystopping callback.

544
00:28:37,000 --> 00:28:41,000
And I've told you what is the importance of early stopping callback.

545
00:28:41,000 --> 00:28:47,000
Now for training the model, I will just go ahead and say, hey, history is equal to nothing but model

546
00:28:47,000 --> 00:28:47,000
dot fit.

547
00:28:48,000 --> 00:28:48,000
Okay.

548
00:28:48,000 --> 00:28:56,000
And here, uh, I'm going to give my X train comma Y train okay.

549
00:28:56,000 --> 00:28:57,000
Comma.

550
00:28:57,000 --> 00:29:00,000
Along with this I'm also going to give my validation underscore data.

551
00:29:02,000 --> 00:29:05,000
Validation on the score data will be the combination of x test.

552
00:29:05,000 --> 00:29:07,000
Comma y test.

553
00:29:07,000 --> 00:29:12,000
Understand this y test data will be used for comparison with respect to the accuracy.

554
00:29:12,000 --> 00:29:15,000
Then I'm going to say hey, run it for 100 epochs.

555
00:29:15,000 --> 00:29:17,000
Let's say I'm saying go ahead and run it for 100 epochs.

556
00:29:17,000 --> 00:29:21,000
And finally I'm also going to apply my callbacks.

557
00:29:21,000 --> 00:29:26,000
So this callbacks is nothing but two callbacks I'm going to apply.

558
00:29:26,000 --> 00:29:27,000
One is TensorFlow callback.

559
00:29:29,000 --> 00:29:35,000
And the other one is specifically my other callback, which I am going to use, which is nothing but

560
00:29:35,000 --> 00:29:37,000
early stopping callback.

561
00:29:37,000 --> 00:29:42,000
Okay, so this two callback I'm going to basically see.

562
00:29:42,000 --> 00:29:49,000
And then uh, after we train this entire model, uh, we will load our entire TensorBoard that I will

563
00:29:49,000 --> 00:29:51,000
show you how it is basically done.

564
00:29:51,000 --> 00:29:53,000
But over here you will be able to see my logs.

565
00:29:53,000 --> 00:29:55,000
File will start getting created.

566
00:29:55,000 --> 00:29:55,000
Okay.

567
00:29:55,000 --> 00:30:00,000
So let's quickly, uh, go ahead and uh, you know, execute this.

568
00:30:00,000 --> 00:30:02,000
And I hope everyone things should work fine.

569
00:30:02,000 --> 00:30:04,000
So I will just go ahead and hit execution.

570
00:30:04,000 --> 00:30:08,000
Now here you can see my epochs has started right.

571
00:30:08,000 --> 00:30:10,000
Initially I'm getting the accuracy over here.

572
00:30:10,000 --> 00:30:11,000
Validation accuracy is over here.

573
00:30:12,000 --> 00:30:20,000
And uh, you can see I told to run it for 100 epochs, but this is just stopped at seven.

574
00:30:20,000 --> 00:30:21,000
Okay, let me do one thing.

575
00:30:21,000 --> 00:30:24,000
Let me increase this patience level to ten.

576
00:30:24,000 --> 00:30:25,000
Okay?

577
00:30:25,000 --> 00:30:28,000
I'm saying, hey, try to just see till ten epochs.

578
00:30:28,000 --> 00:30:29,000
Now let's go ahead and execute it.

579
00:30:30,000 --> 00:30:32,000
So here you can see accuracy is 85 validation.

580
00:30:32,000 --> 00:30:37,000
This one I think we are getting the best validation loss till here okay.

581
00:30:37,000 --> 00:30:39,000
It will wait for the ten.

582
00:30:39,000 --> 00:30:42,000
Now in the 16th 17th epoch, it has stopped, right?

583
00:30:42,000 --> 00:30:44,000
And this is all the values that I get.

584
00:30:44,000 --> 00:30:45,000
I get my loss.

585
00:30:45,000 --> 00:30:48,000
So till 87% I am able to get it.

586
00:30:48,000 --> 00:30:49,000
Validation loss.

587
00:30:49,000 --> 00:30:51,000
I am able to get this much validation accuracy.

588
00:30:51,000 --> 00:30:54,000
I am able to get 0.85 right.

589
00:30:55,000 --> 00:31:01,000
So these are all the information that, uh, you will be seeing over here that we are able to get it

590
00:31:01,000 --> 00:31:02,000
right, which is amazing.

591
00:31:02,000 --> 00:31:06,000
And here you can see that I am able to train the neural network quickly as possible, right?

592
00:31:06,000 --> 00:31:08,000
Uh, let's do one thing.

593
00:31:08,000 --> 00:31:10,000
Let's save this entire model file.

594
00:31:10,000 --> 00:31:13,000
So I will say, hey, go ahead and save this model dot save.

595
00:31:14,000 --> 00:31:17,000
Um, and I'm going to probably create one h5 file.

596
00:31:17,000 --> 00:31:20,000
So h5 file will be compatible with Keras.

597
00:31:20,000 --> 00:31:22,000
So that is the reason I'm actually creating it.

598
00:31:22,000 --> 00:31:24,000
So here you can also see model dot h5 file.

599
00:31:24,000 --> 00:31:27,000
Okay uh let's do one thing.

600
00:31:27,000 --> 00:31:28,000
Let's load.

601
00:31:29,000 --> 00:31:34,000
load TensorBoard extension.

602
00:31:34,000 --> 00:31:34,000
Okay.

603
00:31:37,000 --> 00:31:38,000
So let's load this.

604
00:31:38,000 --> 00:31:47,000
So for loading I will just go ahead and write load uh load underscore extension.

605
00:31:47,000 --> 00:31:51,000
And here I'm just going to use TensorBoard.

606
00:31:51,000 --> 00:31:59,000
Now this extension also we need to install in our uh so here you can see line magic function uh load

607
00:31:59,000 --> 00:32:03,000
underscore extension not found I think the spelling is wrong over here.

608
00:32:03,000 --> 00:32:04,000
I just need to write like this.

609
00:32:04,000 --> 00:32:07,000
So here you can see I have launched my TensorBoard session.

610
00:32:07,000 --> 00:32:09,000
It looks something like this.

611
00:32:09,000 --> 00:32:15,000
Then what I will do, I will just go ahead and say, hey, take this TensorBoard, my magic function.

612
00:32:15,000 --> 00:32:15,000
Okay.

613
00:32:16,000 --> 00:32:19,000
And along with this, use this log directory.

614
00:32:19,000 --> 00:32:24,000
And inside that log directory I have my logs slash fit folder okay.

615
00:32:25,000 --> 00:32:28,000
So this is how you load this entire tensor board.

616
00:32:28,000 --> 00:32:31,000
Now if you see inside this logs this is nothing.

617
00:32:31,000 --> 00:32:36,000
But it has your entire information with respect to training and with respect to validation.

618
00:32:36,000 --> 00:32:36,000
Okay.

619
00:32:36,000 --> 00:32:41,000
And it is just going to load this and it is showing going to show us in this visualized format.

620
00:32:41,000 --> 00:32:42,000
Let's see this.

621
00:32:42,000 --> 00:32:42,000
Okay.

622
00:32:43,000 --> 00:32:48,000
So here, uh, you will be able to see it I think it is getting loaded.

623
00:32:48,000 --> 00:32:54,000
Let's see whether it is getting loaded or not so quickly.

624
00:32:54,000 --> 00:32:56,000
I think it should get loaded.

625
00:32:56,000 --> 00:32:56,000
Yes.

626
00:32:56,000 --> 00:33:01,000
So it says hey uh um.

627
00:33:01,000 --> 00:33:01,000
Mhm.

628
00:33:01,000 --> 00:33:05,000
So it says hey no dashboards are active for the current data.

629
00:33:05,000 --> 00:33:08,000
The problem may be let's go ahead and launch this.

630
00:33:09,000 --> 00:33:09,000
Uh sorry.

631
00:33:09,000 --> 00:33:11,000
Let's go.

632
00:33:11,000 --> 00:33:12,000
Okay.

633
00:33:12,000 --> 00:33:15,000
See what you have to do is that let me click it over here.

634
00:33:15,000 --> 00:33:19,000
Click over here right launch TensorBoard session okay.

635
00:33:20,000 --> 00:33:24,000
Now in this TensorBoard session just click and launch over here.

636
00:33:24,000 --> 00:33:28,000
You'll be able to see use Current Working directory or select another folder.

637
00:33:28,000 --> 00:33:31,000
I will go ahead and select another folder and let me just go ahead and click this.

638
00:33:31,000 --> 00:33:34,000
And let me just go ahead and inside this particular folder.

639
00:33:34,000 --> 00:33:41,000
And let's go ahead and select this train folder okay I will say hey just go ahead and load this train

640
00:33:41,000 --> 00:33:41,000
folder.

641
00:33:41,000 --> 00:33:43,000
Let's see whether it will load or not.

642
00:33:43,000 --> 00:33:47,000
I think it is not able to find out this log fit directory which is already there.

643
00:33:47,000 --> 00:33:48,000
Okay.

644
00:33:48,000 --> 00:33:49,000
That is the problem.

645
00:33:49,000 --> 00:33:52,000
See okay okay I got it now okay.

646
00:33:52,000 --> 00:33:54,000
The problem is what Right.

647
00:33:54,000 --> 00:33:57,000
It is trying to find out this log slash fit folder.

648
00:33:57,000 --> 00:34:00,000
But this is the folder name that I'm actually getting.

649
00:34:00,000 --> 00:34:04,000
So let me just go ahead and write log fit folder okay.

650
00:34:06,000 --> 00:34:13,000
Let's see I think it should uh, replace the name or I can just give that particular folder name over

651
00:34:13,000 --> 00:34:18,000
here, even though if I execute it here, you'll be able to see that I'll not be able to get it because

652
00:34:18,000 --> 00:34:19,000
this is getting renamed.

653
00:34:19,000 --> 00:34:19,000
Okay.

654
00:34:20,000 --> 00:34:22,000
So let me quickly rename this.

655
00:34:22,000 --> 00:34:25,000
So I will say, hey, reveal in the File Explorer.

656
00:34:25,000 --> 00:34:29,000
Uh uh, inside this logs folder, this is the folder name.

657
00:34:29,000 --> 00:34:30,000
And here is my events.

658
00:34:30,000 --> 00:34:32,000
That is the information that is coming up.

659
00:34:32,000 --> 00:34:33,000
Okay.

660
00:34:33,000 --> 00:34:35,000
So quickly, uh, let me do one thing.

661
00:34:35,000 --> 00:34:37,000
Let me rename it from here.

662
00:34:37,000 --> 00:34:39,000
That would be a little bit faster.

663
00:34:41,000 --> 00:34:46,000
I think it will not allow because the file may be getting used somewhere.

664
00:34:46,000 --> 00:34:48,000
Okay, so let me do one thing.

665
00:34:48,000 --> 00:34:53,000
Let me quickly rename this instead of rename.

666
00:34:53,000 --> 00:34:54,000
Right?

667
00:34:54,000 --> 00:34:58,000
I will just go ahead and take this name entirely okay.

668
00:34:58,000 --> 00:35:06,000
And now I will go back over here and say instead of fit you just go ahead and use this entire name,

669
00:35:06,000 --> 00:35:07,000
okay?

670
00:35:07,000 --> 00:35:13,000
So now I think it should be able to load it because I've given the correct loading directory.

671
00:35:13,000 --> 00:35:15,000
See, I'm not going to edit all these things.

672
00:35:15,000 --> 00:35:20,000
Whatever error that I'm actually facing, I will be showing you so that you will be able to execute

673
00:35:20,000 --> 00:35:20,000
it.

674
00:35:20,000 --> 00:35:21,000
Okay.

675
00:35:21,000 --> 00:35:22,000
That is my main aim.

676
00:35:22,000 --> 00:35:22,000
Okay.

677
00:35:24,000 --> 00:35:28,000
I don't know why we have to probably execute two times or it was getting loaded.

678
00:35:28,000 --> 00:35:29,000
Now here you can see.

679
00:35:29,000 --> 00:35:30,000
beautiful.

680
00:35:30,000 --> 00:35:36,000
You are getting all this diagrams see so here based on epoch accuracy.

681
00:35:36,000 --> 00:35:37,000
Let's go ahead and see this.

682
00:35:37,000 --> 00:35:39,000
Let's say I will just uncheck it.

683
00:35:39,000 --> 00:35:42,000
And here I will just go ahead and write epoch accuracy.

684
00:35:45,000 --> 00:35:48,000
Now with respect to this epoch accuracy you will be able to see.

685
00:35:48,000 --> 00:35:49,000
Let me do one thing.

686
00:35:49,000 --> 00:35:53,000
Let me just uncheck this okay.

687
00:35:53,000 --> 00:35:55,000
So this is my epoch accuracy.

688
00:35:55,000 --> 00:35:56,000
This is my epoch loss.

689
00:35:57,000 --> 00:35:57,000
Okay.

690
00:35:57,000 --> 00:36:02,000
Now see with respect to this epoch loss, uh, you'll be able to see my loss is decreasing.

691
00:36:02,000 --> 00:36:03,000
This is good, right?

692
00:36:04,000 --> 00:36:08,000
Uh, if I close this, uh, over here also, you'll be able to see.

693
00:36:08,000 --> 00:36:09,000
Let's go ahead and use this.

694
00:36:10,000 --> 00:36:11,000
An epoch accuracy.

695
00:36:11,000 --> 00:36:12,000
You'll be able to see this graph.

696
00:36:12,000 --> 00:36:17,000
See, it is increasing from 0.855 to 0.8655.

697
00:36:17,000 --> 00:36:18,000
So this is good.

698
00:36:18,000 --> 00:36:20,000
It is going in this direction right.

699
00:36:20,000 --> 00:36:26,000
And uh you can see what relative step, what value, what accuracy you have actually got.

700
00:36:26,000 --> 00:36:29,000
Every information is basically getting stored over here.

701
00:36:30,000 --> 00:36:34,000
You can also change this value with respect to smoothing.

702
00:36:34,000 --> 00:36:37,000
And here you will be able to see how the accuracy changes.

703
00:36:37,000 --> 00:36:37,000
Right.

704
00:36:38,000 --> 00:36:40,000
See these are some of the parameters.

705
00:36:41,000 --> 00:36:42,000
This is also something very important.

706
00:36:42,000 --> 00:36:44,000
Uh, the dense underscore three.

707
00:36:44,000 --> 00:36:44,000
Right.

708
00:36:45,000 --> 00:36:52,000
This, uh, uh, it just looks like, uh, say, uh, if you have seen this histogram, it just looks

709
00:36:52,000 --> 00:36:54,000
like a gradient descent in opposite manner.

710
00:36:54,000 --> 00:36:54,000
Right.

711
00:36:54,000 --> 00:36:59,000
This is the maximum top pick and this is the minimum loss we are able to get right.

712
00:36:59,000 --> 00:37:00,000
Which looks like this over here.

713
00:37:01,000 --> 00:37:04,000
So here also you can probably observe each and every this.

714
00:37:04,000 --> 00:37:08,000
But the main thing is epoch accuracy and epoch loss which you are able to see it over here.

715
00:37:08,000 --> 00:37:11,000
Not only that, uh, let's do one thing.

716
00:37:11,000 --> 00:37:14,000
Let's, uh, instead of taking train, let's go ahead and see validation.

717
00:37:14,000 --> 00:37:16,000
Now in validation you have this epoch accuracy.

718
00:37:17,000 --> 00:37:22,000
Um, so here again there is some up and down, but at least you are able to get it to 0.855.

719
00:37:23,000 --> 00:37:29,000
Um, then you also have this epoch loss, epoch accuracy versus iteration, epoch loss versus iteration.

720
00:37:29,000 --> 00:37:31,000
So please go ahead and check this out.

721
00:37:31,000 --> 00:37:32,000
Uh, entirely.

722
00:37:32,000 --> 00:37:34,000
I've already shown you how to do it.

723
00:37:34,000 --> 00:37:36,000
Uh, first of all, you need to set this entire logs.

724
00:37:36,000 --> 00:37:38,000
Whatever folder name you are probably getting.

725
00:37:38,000 --> 00:37:40,000
You have to probably use that.

726
00:37:40,000 --> 00:37:40,000
Okay.

727
00:37:41,000 --> 00:37:45,000
Um, but still, you need to think why that folder came in that way.

728
00:37:45,000 --> 00:37:46,000
Okay?

729
00:37:46,000 --> 00:37:46,000
Okay.

730
00:37:46,000 --> 00:37:48,000
I was using this plus, right?

731
00:37:48,000 --> 00:37:54,000
Some date sign over here, uh, automatically, with the help of date sign, you could see that, uh,

732
00:37:55,000 --> 00:37:56,000
instead of writing like this, right?

733
00:37:56,000 --> 00:37:58,000
I could have written something like this.

734
00:37:58,000 --> 00:37:59,000
I'll keep this code like this.

735
00:37:59,000 --> 00:37:59,000
Okay.

736
00:37:59,000 --> 00:38:00,000
It will be slash.

737
00:38:00,000 --> 00:38:03,000
And inside that, any date format will be created.

738
00:38:03,000 --> 00:38:04,000
Okay, perfect.

739
00:38:04,000 --> 00:38:12,000
Uh, till here, I think everything looks good, but, uh, always make sure that if I am using this

740
00:38:12,000 --> 00:38:16,000
folder wise over here, let me just show you again.

741
00:38:17,000 --> 00:38:18,000
Please make this change.

742
00:38:18,000 --> 00:38:23,000
So I'm saying, hey, inside the fit folder, you have to probably create every time date, time stamp.

743
00:38:23,000 --> 00:38:25,000
And then you have to probably go ahead and create your logs.

744
00:38:25,000 --> 00:38:31,000
So in this case, uh, you don't even have to use this, right.

745
00:38:32,000 --> 00:38:33,000
You'll be able to get it perfect.

746
00:38:34,000 --> 00:38:37,000
So, uh, this was about this one.

747
00:38:37,000 --> 00:38:38,000
We have also saved the pickle file.

748
00:38:38,000 --> 00:38:41,000
Uh, we have done almost each and every thing.

749
00:38:41,000 --> 00:38:44,000
Uh, and this is how, uh, an neural network is basically created, right?

