﻿1
00:00:00,166 --> 00:00:01,033
Okay, my friends.

2
00:00:01,033 --> 00:00:04,266
So now we're about to have
a very exciting tutorial

3
00:00:04,266 --> 00:00:08,400
because we're about to watch the demo,
you know, the demo of our eye

4
00:00:08,400 --> 00:00:13,733
being built first and trained
and finally making our single predictions.

5
00:00:14,200 --> 00:00:16,800
So this is where we left off
in the previous tutorial.

6
00:00:16,800 --> 00:00:21,133
Basically all the implementation is done
and now I'm going to guide you through

7
00:00:21,166 --> 00:00:24,166
how to run this on Jupyter Notebook.

8
00:00:24,233 --> 00:00:27,500
And therefore the first thing I'll do
will be to download

9
00:00:27,500 --> 00:00:30,866
and install everything
we need to have a Jupyter notebook.

10
00:00:31,200 --> 00:00:35,666
If you already installed Anaconda,
you know which contains Jupyter Notebook,

11
00:00:35,800 --> 00:00:39,800
and if you already have Jupyter notebook
on your machine, then feel free to skip

12
00:00:39,800 --> 00:00:44,300
the five first minutes of this tutorial
and start directly from minute five.

13
00:00:44,300 --> 00:00:44,700
Okay.

14
00:00:44,700 --> 00:00:47,300
This is when we will start
using Jupyter Notebook,

15
00:00:47,300 --> 00:00:50,200
and for the rest of you,
well follow me and will guide you

16
00:00:50,200 --> 00:00:54,500
through the installation of Anaconda
and therefore Jupyter Notebook.

17
00:00:54,866 --> 00:00:58,300
So let's open a new search tab
on your favorite browser.

18
00:00:58,300 --> 00:01:02,100
And in the search bar let's type
and conduct.

19
00:01:02,100 --> 00:01:03,300
There we go.

20
00:01:03,300 --> 00:01:06,433
So Anaconda
then we're going to go to the first link.

21
00:01:06,733 --> 00:01:09,100
Anaconda has become so popular now.

22
00:01:09,100 --> 00:01:15,333
And we're going to go to well get started
and install Anaconda Individual Edition.

23
00:01:15,800 --> 00:01:18,433
Then you can click download here.

24
00:01:18,433 --> 00:01:23,866
And then you're going to choose
the Anaconda installer for your system,

25
00:01:23,866 --> 00:01:26,866
whether you have a windows,
Mac OS or Linux.

26
00:01:27,200 --> 00:01:29,666
I'm on Mac OS,
so I'm going to go for this.

27
00:01:29,666 --> 00:01:33,833
And you're going to take the graphic
installer, not the command line installer.

28
00:01:34,200 --> 00:01:34,466
All right.

29
00:01:34,466 --> 00:01:38,233
So graphic installer and you're going to
take the Python 3.7 version.

30
00:01:38,400 --> 00:01:40,166
Not the Python 2.7 right.

31
00:01:40,166 --> 00:01:42,733
So only this row here.

32
00:01:42,733 --> 00:01:44,000
So choose your system.

33
00:01:44,000 --> 00:01:48,033
Click the file
and this will download Anaconda.

34
00:01:48,033 --> 00:01:50,100
You know the installer.

35
00:01:50,100 --> 00:01:53,966
And in a few seconds you'll get
you know the installer on your machine

36
00:01:53,966 --> 00:01:57,500
probably in your download folder
which is done for me.

37
00:01:57,733 --> 00:01:58,400
Good.

38
00:01:58,400 --> 00:02:01,400
So let's just get rid of this download.

39
00:02:01,500 --> 00:02:04,333
And now let's go to my machine.
There we go.

40
00:02:04,333 --> 00:02:08,500
This is my download folder
on which the installer was download it.

41
00:02:08,966 --> 00:02:11,966
So make sure to find it
and then double click it.

42
00:02:12,066 --> 00:02:15,200
And this will launch
the installation of Anaconda.

43
00:02:15,566 --> 00:02:20,066
Here you can just click
continue continue continue continue.

44
00:02:20,266 --> 00:02:22,866
Just click agree and continue.
You can read that if you want

45
00:02:22,866 --> 00:02:24,700
and then install.

46
00:02:24,700 --> 00:02:26,400
Then this will install Anaconda.

47
00:02:26,400 --> 00:02:30,466
This will just take a few seconds
not more than one minute.

48
00:02:30,966 --> 00:02:33,266
And you know okay less than a minute.

49
00:02:33,266 --> 00:02:34,966
There we go. Good.

50
00:02:34,966 --> 00:02:37,200
So right now Anaconda is installing.

51
00:02:37,200 --> 00:02:39,300
And let me tell you
a few words about Anaconda.

52
00:02:39,300 --> 00:02:43,366
So this is basically a platform
that contains several Ides

53
00:02:43,366 --> 00:02:44,633
on which you can code

54
00:02:44,633 --> 00:02:48,666
in Python and even R, because you will see
that it contains now hours to you.

55
00:02:48,966 --> 00:02:54,900
But the Python Ides that it contains
include Jupyter Notebook and also Spyder.

56
00:02:54,900 --> 00:02:58,133
Spyder
is another great IDE to code in Python,

57
00:02:58,133 --> 00:02:58,933
but here

58
00:02:58,933 --> 00:03:03,033
we're going to go with Jupyter Notebook
because we have been used to, you know,

59
00:03:03,033 --> 00:03:06,566
the Ipynb format, which was the format
we used on Google Colab.

60
00:03:06,933 --> 00:03:12,133
But this time, since we have a huge data
set which we can't import on Google Colab,

61
00:03:12,300 --> 00:03:15,300
well, we're going to run this with Jupyter
Notebook.

62
00:03:15,966 --> 00:03:18,400
All right. So let's see where we are.

63
00:03:18,400 --> 00:03:22,200
So still installing
well you know running the package scripts.

64
00:03:22,533 --> 00:03:26,766
But you will have Anaconda on your machine
with no issue.

65
00:03:27,366 --> 00:03:27,600
All right.

66
00:03:27,600 --> 00:03:32,033
So here this is just to give indeed access
to your downloads folder.

67
00:03:32,033 --> 00:03:33,666
So of course you click okay.

68
00:03:33,666 --> 00:03:36,400
And then it should progress now.

69
00:03:36,400 --> 00:03:38,100
All right let's see.

70
00:03:39,133 --> 00:03:39,866
And there we go.

71
00:03:39,866 --> 00:03:41,933
Perfect. So now we have Anaconda.

72
00:03:41,933 --> 00:03:45,966
You can click continue and installation
and yes close.

73
00:03:46,266 --> 00:03:50,066
And then you can either choose to keep
the installer or remove it as you want.

74
00:03:50,066 --> 00:03:51,300
I'll just keep it.

75
00:03:51,300 --> 00:03:53,366
All right. So good. Now we have Anaconda.

76
00:03:53,366 --> 00:03:54,966
Then it's not over.

77
00:03:54,966 --> 00:03:56,900
We still need to install a few things.

78
00:03:56,900 --> 00:03:59,900
And these things are unfortunately

79
00:04:00,033 --> 00:04:03,200
the TensorFlow library
and the Keras library.

80
00:04:03,566 --> 00:04:07,166
Because I remind that
the beauty of Google Colab and the reason

81
00:04:07,166 --> 00:04:10,166
why I wanted to code everything on Google
Colab

82
00:04:10,200 --> 00:04:14,100
was that we didn't have anything
to install because all the libraries

83
00:04:14,100 --> 00:04:17,800
and packages are already pre-installed,
except for the rare ones.

84
00:04:18,133 --> 00:04:21,566
But here on Jupyter
Notebook or Spyder or any Anaconda

85
00:04:21,566 --> 00:04:25,466
ID, well,
we have to install manually the packages.

86
00:04:25,466 --> 00:04:28,333
And that's exactly what I'm about
to show you.

87
00:04:28,333 --> 00:04:34,033
So for Mac and Linux users,
please open your terminal Linux users.

88
00:04:34,033 --> 00:04:35,266
You'll find it very easily.

89
00:04:35,266 --> 00:04:39,033
And Mac users, well,
you can just press command plus space.

90
00:04:39,033 --> 00:04:42,233
And then in the spotlight search
you can type terminal.

91
00:04:42,500 --> 00:04:44,466
And this will open your terminal.

92
00:04:44,466 --> 00:04:47,400
And for windows users
no worries I'm not forgetting you.

93
00:04:47,400 --> 00:04:49,500
Windows users, please go.

94
00:04:49,500 --> 00:04:53,700
You know, at the lower left
corner of your monitor, please click

95
00:04:53,700 --> 00:04:58,000
that window button and then find Anaconda
in your list of programs.

96
00:04:58,266 --> 00:05:01,666
And in the Anaconda tab
you will find Command Prompt.

97
00:05:02,000 --> 00:05:06,333
Then please click it and this will be
the equivalent of the terminal

98
00:05:06,333 --> 00:05:10,400
on which you can run commands
to install packages from the web.

99
00:05:11,033 --> 00:05:13,333
All right.
So now we should all be on the same page.

100
00:05:13,333 --> 00:05:15,933
You know,
windows users, Mac users or Linux users.

101
00:05:15,933 --> 00:05:19,100
And we're about to install TensorFlow
and Keras.

102
00:05:19,100 --> 00:05:22,400
And you will see that
it will be still super quick and easy,

103
00:05:22,800 --> 00:05:26,300
because the simple commands
that we have to enter here

104
00:05:26,300 --> 00:05:29,800
in order to install TensorFlow
and Keras are the following.

105
00:05:29,800 --> 00:05:32,700
So we have to enter them
separately. Let's start with TensorFlow.

106
00:05:32,700 --> 00:05:36,433
We simply need to enter pip, then install

107
00:05:36,733 --> 00:05:39,900
and then tensor flow.

108
00:05:40,233 --> 00:05:40,666
All right.

109
00:05:40,666 --> 00:05:42,966
And then we just need to press enter.

110
00:05:42,966 --> 00:05:46,400
And this will download
TensorFlow from the web

111
00:05:46,400 --> 00:05:50,233
and install it
on your Anaconda environment.

112
00:05:50,400 --> 00:05:50,800
All right.

113
00:05:50,800 --> 00:05:55,500
So right now as you can see
it is downloading it and installing it.

114
00:05:55,933 --> 00:05:57,900
All right. So don't worry about all this.

115
00:05:57,900 --> 00:06:01,400
This is totally fine right
C installing connected packages

116
00:06:01,866 --> 00:06:03,866
including indeed TensorFlow.

117
00:06:03,866 --> 00:06:05,533
So it is not only installing TensorFlow

118
00:06:05,533 --> 00:06:09,800
but also some what we call dependencies
which work with TensorFlow.

119
00:06:09,800 --> 00:06:11,700
But please don't worry about all this.

120
00:06:11,700 --> 00:06:14,700
This will just install TensorFlow
which is exactly what we need.

121
00:06:15,000 --> 00:06:16,800
Okay, good. So installation done.

122
00:06:16,800 --> 00:06:21,866
As we can see successfully installed all
these dependencies including TensorFlow.

123
00:06:22,300 --> 00:06:23,900
And now to install Keras.

124
00:06:23,900 --> 00:06:25,000
Well we're going to do the same.

125
00:06:25,000 --> 00:06:28,000
We're going to enter pip and then install

126
00:06:28,066 --> 00:06:31,000
and then Keras and then press enter.

127
00:06:31,000 --> 00:06:34,500
And this will install
Keras on your machine.

128
00:06:34,500 --> 00:06:36,866
There we go successfully installed Keras.

129
00:06:36,866 --> 00:06:39,033
And that's the version
that we just installed.

130
00:06:39,033 --> 00:06:43,266
You might get a different version if you
take this course way after I recorded it.

131
00:06:43,933 --> 00:06:46,100
Good. Done with the terminal?

132
00:06:46,100 --> 00:06:48,900
No worries,
we won't have to deal with it anymore.

133
00:06:48,900 --> 00:06:51,300
I hope it wasn't too traumatizing for you.

134
00:06:51,300 --> 00:06:53,733
Know, those of you
who used it for the first time,

135
00:06:53,733 --> 00:06:57,133
as I know it can be a bit
surprising at first, but indeed, this

136
00:06:57,133 --> 00:07:01,666
is the classic way of installing packages
when you're not working on Google Colab.

137
00:07:02,100 --> 00:07:03,900
So then you can quit the terminal.

138
00:07:03,900 --> 00:07:05,166
And then there we go.

139
00:07:05,166 --> 00:07:10,233
Now we we're ready to finally open
Anaconda and mostly open

140
00:07:10,233 --> 00:07:11,200
Jupyter Notebook.

141
00:07:11,200 --> 00:07:15,266
So we're going to find Anaconda in either,
you know, the list of applications

142
00:07:15,266 --> 00:07:16,033
from Mac users

143
00:07:16,033 --> 00:07:20,933
or in your list of programs for windows
users and same for Linux users.

144
00:07:21,233 --> 00:07:23,766
So on Mac here is Anaconda.

145
00:07:23,766 --> 00:07:27,433
So let's just double click it
and this will open it.

146
00:07:27,700 --> 00:07:30,900
I can just go back to,
you know, my desktop here

147
00:07:31,366 --> 00:07:33,866
because Anaconda is now opening.

148
00:07:33,866 --> 00:07:39,300
And in a second we should see that
beautiful platform, very user friendly,

149
00:07:39,300 --> 00:07:43,700
containing all the different Ides
on which you can code with Python.

150
00:07:43,866 --> 00:07:46,033
All right. Loading applications.

151
00:07:46,033 --> 00:07:48,300
And in a second there we go.

152
00:07:48,300 --> 00:07:51,233
Welcome to Anaconda. Good.

153
00:07:51,233 --> 00:07:53,600
So as I told you you have several Ides.

154
00:07:53,600 --> 00:07:55,166
You have this studio for all,

155
00:07:55,166 --> 00:07:59,700
but you have several of them for Python,
including Jupyter Notebook and Spyder.

156
00:07:59,700 --> 00:08:03,833
And as we said, we're going to run
our implementation on Jupyter Notebook.

157
00:08:03,833 --> 00:08:05,866
So here we're going to click launch.

158
00:08:05,866 --> 00:08:06,833
All right.

159
00:08:06,833 --> 00:08:09,000
And this will launch Jupyter Notebook.

160
00:08:09,000 --> 00:08:12,633
And this will automatically open it
on a new tab on your browser.

161
00:08:12,633 --> 00:08:14,500
You'll see
we should see pop up in a second.

162
00:08:14,500 --> 00:08:15,366
There we go.

163
00:08:15,366 --> 00:08:17,333
So welcome to Jupyter Notebook.

164
00:08:17,333 --> 00:08:18,900
So this is your machine.

165
00:08:18,900 --> 00:08:21,300
You will recognize
the folders of your machine.

166
00:08:21,300 --> 00:08:21,933
And of course

167
00:08:21,933 --> 00:08:26,633
now you're going to go to the folder
that contains, you know, the data set.

168
00:08:26,633 --> 00:08:30,066
Know what you downloaded at the beginning
of this practical activity.

169
00:08:30,400 --> 00:08:32,966
So remember mine is on my desktop.

170
00:08:32,966 --> 00:08:37,333
And here is the folder, you know, section
40 convolutional neural networks.

171
00:08:37,533 --> 00:08:38,933
So we're going to click it.

172
00:08:38,933 --> 00:08:39,733
And inside.

173
00:08:39,733 --> 00:08:42,566
Well as you notice
I only kept the data set.

174
00:08:42,566 --> 00:08:46,700
I removed the two previous implementations
which were in that folder.

175
00:08:46,900 --> 00:08:52,466
Because now what I want to do
is actually take our exact implementation.

176
00:08:52,466 --> 00:08:55,433
We code it during this practical activity.

177
00:08:55,433 --> 00:08:58,600
I'm going to download it
by clicking file here

178
00:08:58,800 --> 00:09:01,933
and then download dot ipynb.

179
00:09:01,933 --> 00:09:06,600
Make sure it's a Ipy and B, because that's
the format used for Jupyter Notebook.

180
00:09:07,000 --> 00:09:09,566
All right then I'm going to close this.

181
00:09:09,566 --> 00:09:13,100
And now we're going to go to where
this was downloaded

182
00:09:13,133 --> 00:09:18,166
meaning in the downloads folder
we're going to put that into this folder

183
00:09:18,233 --> 00:09:21,533
you know containing the data
set right here.

184
00:09:21,533 --> 00:09:23,533
So you have to put it
in the exact same folder.

185
00:09:23,533 --> 00:09:27,366
That's important because you have to run
this file and Jupyter

186
00:09:27,366 --> 00:09:31,633
notebook within the same directory folder
that contains the data set.

187
00:09:31,633 --> 00:09:33,966
That's why it's important to do it.

188
00:09:33,966 --> 00:09:37,366
So this is the exact implementation we,
you know, coded together

189
00:09:37,366 --> 00:09:38,666
during the practical activity.

190
00:09:38,666 --> 00:09:40,533
And now we're going to check that it works

191
00:09:40,533 --> 00:09:44,100
by running each
and every single one of the cells.

192
00:09:44,500 --> 00:09:45,300
So let's do this.

193
00:09:45,300 --> 00:09:50,700
Let's go back to Jupyter Notebook
which is right here okay good.

194
00:09:50,800 --> 00:09:53,800
And now indeed we have
well our implementation.

195
00:09:53,900 --> 00:09:56,900
Good.
So let's open it by just clicking it.

196
00:09:57,000 --> 00:10:02,266
And welcome to our implementation
of the Convolutional Neural Network.

197
00:10:02,700 --> 00:10:05,400
And now now is really the Showtime.

198
00:10:05,400 --> 00:10:08,366
Because the only thing will have to do
will be to click

199
00:10:08,366 --> 00:10:11,733
this run button cell after cell,
even the text cell.

200
00:10:11,733 --> 00:10:15,133
You know, we'll just start
from the beginning and see what happens.

201
00:10:15,600 --> 00:10:17,000
Okay. So are you ready?

202
00:10:17,000 --> 00:10:19,300
Let me just,
you know, clear all the outputs

203
00:10:19,300 --> 00:10:21,833
which were the outputs
we got in Google Colab.

204
00:10:21,833 --> 00:10:24,166
So to do this we can click kernel here.

205
00:10:24,166 --> 00:10:27,266
And then restart and clear output. Right.

206
00:10:27,800 --> 00:10:28,966
We won't get these outputs.

207
00:10:28,966 --> 00:10:31,933
We will just really start from scratch
okay.

208
00:10:31,933 --> 00:10:33,000
Good.

209
00:10:33,000 --> 00:10:36,666
So now let's do this 3 to 1.

210
00:10:36,900 --> 00:10:38,433
Go run okay.

211
00:10:38,433 --> 00:10:41,766
So that doesn't run anything
because this is a text cell run again.

212
00:10:41,766 --> 00:10:43,200
And now it is starting.

213
00:10:43,200 --> 00:10:45,733
So we're going to click our first run
for the first cell.

214
00:10:45,733 --> 00:10:48,166
And this will import TensorFlow.

215
00:10:48,166 --> 00:10:51,433
This means that it is running right now
you know the cell is running.

216
00:10:51,733 --> 00:10:55,766
And when it is done running
we will see the first number one meaning

217
00:10:55,766 --> 00:11:00,533
that the cell is successfully run okay
there we go using TensorFlow back end.

218
00:11:00,533 --> 00:11:02,833
That's the output of this cell.

219
00:11:02,833 --> 00:11:06,600
And in order for this to work
this way will make sure to have run

220
00:11:06,600 --> 00:11:10,266
like me the pip install
commands of TensorFlow and Keras.

221
00:11:10,800 --> 00:11:12,633
All right. Good. Now let's check
the version.

222
00:11:12,633 --> 00:11:16,166
It's still going to be
you know TensorFlow 22.2.0.

223
00:11:16,566 --> 00:11:18,766
And then let's just run
the rest of the cells.

224
00:11:18,766 --> 00:11:19,500
There we go.

225
00:11:19,500 --> 00:11:22,800
So now we're entering part
one preprocess the training set.

226
00:11:23,100 --> 00:11:26,700
And now running this cell
we will get in the output that indeed

227
00:11:26,933 --> 00:11:30,600
we imported and preprocessed
you know with data augmentation

228
00:11:30,866 --> 00:11:35,100
8000 images
belonging to two classes dogs and cats.

229
00:11:35,466 --> 00:11:38,633
Okay then let's click
run for the next cell.

230
00:11:38,666 --> 00:11:40,266
Preprocessing the test set.

231
00:11:40,266 --> 00:11:43,200
And now running this cell,
we will get indeed

232
00:11:43,200 --> 00:11:46,666
this time
2000 images belonging to two classes.

233
00:11:46,666 --> 00:11:49,500
And of course no image
augmentation was applied.

234
00:11:49,500 --> 00:11:52,033
Only feature scaling was applied.

235
00:11:52,033 --> 00:11:52,500
All right.

236
00:11:52,500 --> 00:11:55,233
And now entering part
two building the CNN.

237
00:11:55,233 --> 00:11:56,233
So there we go.

238
00:11:56,233 --> 00:11:59,966
First we initialize the CNN
as a sequence of layers.

239
00:12:00,300 --> 00:12:03,300
Then we start the first step, step
one convolution

240
00:12:03,466 --> 00:12:07,300
where we add a convolutional layer
then pooling.

241
00:12:07,500 --> 00:12:11,366
Let me just scroll down a bit
actually right then pooling.

242
00:12:11,366 --> 00:12:14,733
So here we apply max pooling to this
first convolutional layer.

243
00:12:15,100 --> 00:12:16,133
Good. Done.

244
00:12:16,133 --> 00:12:18,766
Then we add a second convolutional layer.

245
00:12:18,766 --> 00:12:21,500
And at the same time we apply max pooling.

246
00:12:21,500 --> 00:12:22,333
Done.

247
00:12:22,333 --> 00:12:24,100
Then we proceed to step three

248
00:12:24,100 --> 00:12:27,733
where we flatten the result
of all these convolutions and pooling

249
00:12:28,000 --> 00:12:32,900
into a one dimensional single vector,
which will become.

250
00:12:32,900 --> 00:12:37,600
In this new step for full connection,
the input of a fully connected

251
00:12:37,600 --> 00:12:40,833
neural network,
which will contain only one fully

252
00:12:40,833 --> 00:12:43,900
connected layer with this cell
that we're about to run.

253
00:12:44,133 --> 00:12:44,966
Done.

254
00:12:44,966 --> 00:12:47,366
And now let me scroll down a bit again.

255
00:12:47,366 --> 00:12:49,900
Right. Let's scroll down like that okay.

256
00:12:49,900 --> 00:12:54,000
And now in the final step
of the construction process of our CNN,

257
00:12:54,100 --> 00:12:57,233
we will connect all these
to the final output

258
00:12:57,233 --> 00:13:00,233
layer
which will contain the final prediction.

259
00:13:00,300 --> 00:13:00,633
Right.

260
00:13:00,633 --> 00:13:03,000
So let's run this cell and there we go.

261
00:13:03,000 --> 00:13:05,700
Now we're done building the CNN.

262
00:13:05,700 --> 00:13:07,300
Everything looks good so far.

263
00:13:07,300 --> 00:13:11,700
We now have a brain with some eyes
that are able to see images.

264
00:13:11,700 --> 00:13:14,200
You know,
just like we humans do with our eyes.

265
00:13:14,200 --> 00:13:18,700
And now now that we have this brain
and these eyes will time to make them

266
00:13:18,700 --> 00:13:24,633
smart by training the CNN
to recognize cats and dogs in images.

267
00:13:25,066 --> 00:13:25,766
So there we go.

268
00:13:25,766 --> 00:13:29,433
We end to part three now,
first compiling the CNN

269
00:13:29,433 --> 00:13:33,133
with an Adam optimizer, which will perform
stochastic gradient descent.

270
00:13:33,300 --> 00:13:36,466
The best way
then a binary cross entropy loss function.

271
00:13:36,466 --> 00:13:41,333
Because we're doing binary classification
and an accuracy metrics there, we go.

272
00:13:41,333 --> 00:13:43,666
Now our CNN is compiled.

273
00:13:43,666 --> 00:13:46,666
And now now, my friends,
it's time for the training.

274
00:13:46,700 --> 00:13:47,700
Are you ready.

275
00:13:47,700 --> 00:13:52,066
This following cell
will run the training for 25 epochs.

276
00:13:52,433 --> 00:13:57,000
And at the same time
we will get the accuracy on the test set.

277
00:13:57,000 --> 00:14:00,433
So this will be very exciting
because we will see the accuracy on both

278
00:14:00,433 --> 00:14:04,400
the training set and a data set
getting increased and increased over time.

279
00:14:05,066 --> 00:14:05,966
Are you ready?

280
00:14:05,966 --> 00:14:07,733
I'm not going to make us wait longer.

281
00:14:07,733 --> 00:14:08,500
There we go.

282
00:14:08,500 --> 00:14:10,233
Now the training is starting.

283
00:14:10,233 --> 00:14:13,066
There we go with the first epoch
one of 25.

284
00:14:13,066 --> 00:14:16,066
And here you see the loss, the accuracy.

285
00:14:16,200 --> 00:14:19,000
You know, progressing, increasing.

286
00:14:19,000 --> 00:14:23,200
So basically the 250 here correspond

287
00:14:23,200 --> 00:14:26,200
to the fact that,
you know, the batch size is 32.

288
00:14:26,233 --> 00:14:28,800
And we have in total 8000 images.

289
00:14:28,800 --> 00:14:33,333
So that's, you know, 32 times
250 equals 8000.

290
00:14:33,600 --> 00:14:36,633
So basically,
you know, we have 32 images in the batch

291
00:14:36,900 --> 00:14:40,966
and we have 250 steps in each epoch

292
00:14:41,100 --> 00:14:44,566
to, you know,
reach the total amount of 8000 images.

293
00:14:45,266 --> 00:14:47,500
All right. So first epoch done.
Let's see what we got.

294
00:14:47,500 --> 00:14:52,433
We got an accuracy of 61%
on the training set.

295
00:14:52,433 --> 00:14:53,333
Be careful.

296
00:14:53,333 --> 00:14:59,700
And on the data set we got an accuracy
of 67.75% which is pretty good.

297
00:15:00,400 --> 00:15:00,900
All right.

298
00:15:00,900 --> 00:15:02,866
And now the other epochs are running.

299
00:15:02,866 --> 00:15:04,800
But as you can see
it's going to take some time.

300
00:15:04,800 --> 00:15:08,766
So I'm just going to do a fast forward
here with some exciting music

301
00:15:08,933 --> 00:15:13,866
so that we can observe and mostly
admire the results and the progression of,

302
00:15:13,866 --> 00:15:18,033
you know, getting higher
and higher accuracies in accelerated mode.

303
00:15:18,300 --> 00:15:19,500
All right. Are you ready?

304
00:15:19,500 --> 00:15:21,966
3 to 1 action.

305
00:16:09,466 --> 00:16:10,033
All right.

306
00:16:10,033 --> 00:16:11,433
Here I am, back in the game.

307
00:16:11,433 --> 00:16:15,766
I'm super excited to see the final result
here of the 25th epoch.

308
00:16:15,833 --> 00:16:16,533
There we go.

309
00:16:16,533 --> 00:16:20,866
We end up with a final accuracy
on the training set of 89%

310
00:16:21,000 --> 00:16:25,800
and a final accuracy on the test
set of 80%, which is great.

311
00:16:26,033 --> 00:16:30,066
And I remind that if we hadn't done
the image augmentation preprocessing,

312
00:16:30,066 --> 00:16:31,200
you know, in part one,

313
00:16:31,200 --> 00:16:35,133
well, we would have ended up, you know,
you can try with an accuracy here

314
00:16:35,133 --> 00:16:40,133
if the training set around 98 or even 99%,
which clearly indicates

315
00:16:40,133 --> 00:16:45,000
overfitting and a lower accuracy
here on the test set around 70%.

316
00:16:45,433 --> 00:16:50,466
So that's why I insist image
augmentation is absolutely fundamental.

317
00:16:51,166 --> 00:16:53,966
Okay,
so the training is done. There you go.

318
00:16:53,966 --> 00:16:56,233
You had your first advanced training.

319
00:16:56,233 --> 00:16:57,800
Congratulations again.

320
00:16:57,800 --> 00:17:01,766
And now well, let's test
our model in production

321
00:17:01,766 --> 00:17:06,533
by not making
that single prediction of a single image.

322
00:17:07,200 --> 00:17:07,633
All right.

323
00:17:07,633 --> 00:17:11,966
So just before we run this let's just
make sure we know what we're predicting.

324
00:17:12,100 --> 00:17:14,966
So we're going to go back to our folder
which is right here.

325
00:17:14,966 --> 00:17:16,666
We're going to go into our data set.

326
00:17:16,666 --> 00:17:21,033
And remember those single images
are in the single prediction folder.

327
00:17:21,366 --> 00:17:22,800
And we're going to start with this one

328
00:17:22,800 --> 00:17:26,633
character one
which contains of course a dog.

329
00:17:26,666 --> 00:17:27,933
And now we're going to check

330
00:17:27,933 --> 00:17:32,333
that our CNN can predict that indeed
there is a dog inside this image.

331
00:17:32,533 --> 00:17:33,466
Are you ready?

332
00:17:33,466 --> 00:17:36,333
Let's do this.
Where is it? It's right here.

333
00:17:36,333 --> 00:17:38,300
All right. So play.

334
00:17:38,300 --> 00:17:41,433
Now we're first going to play this cell to
you know get the prediction.

335
00:17:41,666 --> 00:17:44,933
Make sure to have cat or dog one here
which corresponds

336
00:17:44,933 --> 00:17:46,833
to the image we just saw.

337
00:17:46,833 --> 00:17:48,600
And now let's play the cell.

338
00:17:48,600 --> 00:17:52,600
And now we're about to get the final
prediction printed in the console.

339
00:17:52,733 --> 00:17:56,333
And we were certainly hoping
to see Doug in the output.

340
00:17:56,666 --> 00:17:57,666
Are you ready.

341
00:17:57,666 --> 00:18:01,633
3 to 1 run and perfect RC

342
00:18:01,633 --> 00:18:05,766
and then predicted that there was a dog
inside the image okay good.

343
00:18:06,000 --> 00:18:08,200
First test passed successfully.

344
00:18:08,200 --> 00:18:10,633
Now let's see for the other image.

345
00:18:10,633 --> 00:18:13,433
This one which contains of course a cat.

346
00:18:13,433 --> 00:18:16,833
So let's deploy our model
on this single image and check

347
00:18:17,066 --> 00:18:20,066
that indeed our CNN returns a cat.

348
00:18:20,066 --> 00:18:21,566
So to do this we just need to,

349
00:18:21,566 --> 00:18:25,433
you know, replace this image
name here by cat or dog two.

350
00:18:25,766 --> 00:18:29,900
Then we can just play this cell again
by just clicking run again.

351
00:18:30,133 --> 00:18:33,766
And now we're going to print this again
to print a new prediction

352
00:18:34,033 --> 00:18:36,566
of this other image. So let's do this.

353
00:18:36,566 --> 00:18:40,933
And let's hope that indeed we get
cat in the output of the console.

354
00:18:41,133 --> 00:18:42,100
Perfect.

355
00:18:42,100 --> 00:18:45,100
So our CNN got all the answers correct.

356
00:18:45,266 --> 00:18:48,000
But what if I make it
even more challenging,

357
00:18:48,000 --> 00:18:51,466
you know, because maybe I was sneaky
and maybe I chose images

358
00:18:51,466 --> 00:18:54,700
in a test set that I checked was working
well with our CNN.

359
00:18:54,700 --> 00:18:57,700
You know, that our CNN was able
to predict correctly.

360
00:18:57,966 --> 00:19:03,300
So to make it more challenging,
my idea is to open a new tab here.

361
00:19:03,533 --> 00:19:08,966
Then in the search bar
I would like to generate random number.

362
00:19:09,566 --> 00:19:12,900
And we're going to generate
a random number using this.

363
00:19:12,900 --> 00:19:15,333
You know the classic tool by Google.

364
00:19:15,333 --> 00:19:18,866
And we're going to generate
a random number from our test set,

365
00:19:18,866 --> 00:19:23,733
you know, which contains the new images
on which the model wasn't trained.

366
00:19:23,966 --> 00:19:27,033
And we're going to take randomly an image
from this test set

367
00:19:27,200 --> 00:19:31,233
and test it as a final test,
you know, for CNN.

368
00:19:31,600 --> 00:19:34,833
So let's
see the images of the dogs in the test set

369
00:19:34,833 --> 00:19:38,400
go from 4001 to 4000.

370
00:19:38,933 --> 00:19:40,300
Well, 5000.

371
00:19:40,300 --> 00:19:45,766
And the cats
go from same 4001 up to once again 5000.

372
00:19:46,200 --> 00:19:47,766
Okay. So let's start with dog.

373
00:19:47,766 --> 00:19:52,300
First let's generate a random number,
you know, between

374
00:19:52,300 --> 00:19:56,100
4000 and 5000.

375
00:19:56,700 --> 00:19:58,433
And let's generate this.

376
00:19:58,433 --> 00:20:01,233
And we get 4689 okay.

377
00:20:01,233 --> 00:20:06,766
So let's get that image 4689
which is a bit below okay.

378
00:20:06,766 --> 00:20:08,933
Right here 4689.

379
00:20:08,933 --> 00:20:09,200
All right.

380
00:20:09,200 --> 00:20:11,300
So that's actually going to be
quite challenging.

381
00:20:11,300 --> 00:20:13,933
Our CNN might not recognize
that it is a dog.

382
00:20:13,933 --> 00:20:14,833
Well let's see.

383
00:20:14,833 --> 00:20:16,166
So I'm going to take that image

384
00:20:16,166 --> 00:20:19,166
I just copied it
and into the single prediction folder

385
00:20:19,266 --> 00:20:22,166
I'm placing it
and I'm going to rename this.

386
00:20:22,166 --> 00:20:26,400
You know I'm going to rename this
cat or dog three.

387
00:20:26,600 --> 00:20:28,600
All right.
So that will be our third image.

388
00:20:28,600 --> 00:20:31,800
And now let's generate
a new number for the cat.

389
00:20:32,466 --> 00:20:35,400
All right 4538.

390
00:20:35,400 --> 00:20:40,200
And so in the test set let's
go into the cats folder and at stake.

391
00:20:40,466 --> 00:20:43,666
Sorry what is it again 4538.

392
00:20:43,666 --> 00:20:47,633
Yes 4538.

393
00:20:47,800 --> 00:20:50,633
Which is right here.

394
00:20:50,633 --> 00:20:51,033
All right.

395
00:20:51,033 --> 00:20:53,233
Whoa. It's going to be challenging again.
Let's see.

396
00:20:53,233 --> 00:20:54,900
We only see a cat head here.

397
00:20:54,900 --> 00:20:56,700
So let's see okay.

398
00:20:56,700 --> 00:20:59,133
Well I didn't expect
such a hard challenge.

399
00:20:59,133 --> 00:21:01,866
But let's see how our CNN
is going to do it anyway.

400
00:21:01,866 --> 00:21:05,433
So I just copied it and into this single
prediction folder let's paste it.

401
00:21:05,966 --> 00:21:09,033
Let's, you know, copy the name of this

402
00:21:09,433 --> 00:21:13,633
and then paste that here to replace that
by cat or dog for.

403
00:21:14,166 --> 00:21:14,700
All right.

404
00:21:14,700 --> 00:21:18,200
So let's deploy our model
on this single image first.

405
00:21:18,466 --> 00:21:22,766
And let's hope that you know it
predicts this time a dog.

406
00:21:23,200 --> 00:21:28,300
So here it is cat or dog three I'm scared.

407
00:21:28,566 --> 00:21:33,000
And let's play run
and then print prediction dog.

408
00:21:33,000 --> 00:21:34,700
Woo hoo. Great.

409
00:21:34,700 --> 00:21:38,500
I was really scared because, you
know, it's not that obvious for a machine

410
00:21:38,500 --> 00:21:41,500
that the dog in the image is a dog,
but that's really good.

411
00:21:41,833 --> 00:21:42,300
Okay.

412
00:21:42,300 --> 00:21:47,633
And now that special cat in this red gift
wrapping thing, cat or dog for.

413
00:21:47,666 --> 00:21:50,966
Let's hope that our model recognizes
that it is a cat.

414
00:21:50,966 --> 00:21:52,633
You know, it's obvious for us humans,

415
00:21:52,633 --> 00:21:56,700
but here we only see a head actually,
you know, with the features of a cat.

416
00:21:56,700 --> 00:21:59,700
So yeah, let's hope that it will work.

417
00:22:00,000 --> 00:22:02,633
So cat or dog four.

418
00:22:02,633 --> 00:22:04,300
And now let's play the cell.

419
00:22:04,300 --> 00:22:05,666
I'm scared again.

420
00:22:05,666 --> 00:22:08,666
And, Excellent.

421
00:22:08,733 --> 00:22:13,366
So 100% correct answers from our CNN.

422
00:22:13,366 --> 00:22:14,266
So that's awesome.

423
00:22:14,266 --> 00:22:16,733
I'm really happy that it worked 100%.

424
00:22:16,733 --> 00:22:21,833
That's because, you know, we have, after
all, an accuracy of 80% on the test set.

425
00:22:22,133 --> 00:22:26,000
So which means that indeed eight
predictions will be correct out of ten.

426
00:22:26,000 --> 00:22:29,833
So yes, even if the images are quite
challenging, you know, with not

427
00:22:29,833 --> 00:22:33,900
some obvious dogs or cats, well,
our model can do pretty well.

428
00:22:34,300 --> 00:22:39,266
So congratulations, you just built a
pretty advanced artificial neural network.

429
00:22:39,266 --> 00:22:42,600
You know, the convolutional neural network
is quite technically advanced.

430
00:22:42,800 --> 00:22:43,933
So congratulations.

431
00:22:43,933 --> 00:22:47,400
And not only you built it,
but mostly you built it successfully.

432
00:22:47,633 --> 00:22:50,633
It is now a really good cat
or dog predictor.

433
00:22:50,833 --> 00:22:53,466
And feel free to,
you know, play the same game by generating

434
00:22:53,466 --> 00:22:58,200
a random number and test some other
single images you might be surprised

435
00:22:58,200 --> 00:23:01,433
by, you know, the predictive
power of the model you just built.

436
00:23:02,200 --> 00:23:04,600
All right,
so we're making great progress here.

437
00:23:04,600 --> 00:23:07,233
Now we done with the deep learning part.

438
00:23:07,233 --> 00:23:10,900
So we're going to move on to the next part
which is about dimensionality reduction

439
00:23:11,166 --> 00:23:14,100
and which is super important for you
in your career because you know

440
00:23:14,100 --> 00:23:17,666
you're going to work with huge data
sets with many, many features.

441
00:23:17,766 --> 00:23:21,766
So you need to have the right tools
in order to reduce the dimensionality

442
00:23:21,766 --> 00:23:25,600
of your data set without losing,
of course, the information you know,

443
00:23:25,600 --> 00:23:29,700
the information that allows to learn
some correlations between the features

444
00:23:29,700 --> 00:23:31,200
and the dependent variable.

445
00:23:31,200 --> 00:23:32,833
So that's a super important chapter.

446
00:23:32,833 --> 00:23:35,833
I'll look forward
to seeing you in this next part.

447
00:23:35,833 --> 00:23:37,833
And until then, enjoy machine learning.
