Hello, guys, and welcome back.
Now it's time to start coding our Deep Learning Model, which is based on CNN or Convolutional Neural
Network, which we have talked about in the past few lectures.
Now, if you remember and if we recap, there are multiple layers that we need to code.
They are convolutional layer pooling layers.
We need a couple of them.
We have, of course, the activation layer and we have the fully connected layer at the end.
And here we are going to learn also some tricks in order to manipulate the image data that we are importing.
OK, so let us go step by step.
First, we need to import some glasses from Kiraz.
And what I mean by class, you can think about it just like a function.
A class is a little bit more advanced data structure, which is related to object oriented programming,
and we have not talked about that in this course, but it's really not that important to know about
it.
And we have seen a little bit of it in the original when we were using some libraries like the Servo
Motor Library, we were using classes without even noticing.
So here it is going to be the same.
Now, before we type anything, we need to save this file.
So I'm going to go file as.
And in document now, let us create a new folder here by clicking on this button.
And we're going to call it CNN now, I'm going to save this in my CNN and I'm going to name this CNN
as well.
OK, click on Save and now we have a bye model.
Now let us start typing.
We need to type from Kiraz DOT model.
So from the Gigas model, I want to import sequential.
Now, sequential is the class that will allow me to compress multiple layers together to stack the layers
together.
OK, next again from this time Kiraz dot layers, I'm going to import gone to the OK, so this is how
we were going to use the convolutional layer by actually using this class going to the next.
Again, from Kiraz, top players we are going to import.
Max pulling.
Remember, Max, polling well, this is how we import class next, I'm going to say from Kiraz, the
players import platen and finally flatten.
We're going to talk about it later.
It's the class that is going to convert the max polling into a form that is acceptable by the dence
layer because, you know, bullying is a mattress.
It's too deep and we need to convert it to some one dimensional mattress so that we can put it in the
fully connected layer, because, as you know, the fully connected low is a bunch of nodes that are
stacked vertically.
And we need to convert that bullying, which is that Odera to that on the array.
The way to do that is by calling the class flat.
And finally, we have from Kiraz the players.
Import dence now dence is actually the fully connected layer.
We're going to use now we need some preprocessing for the images because the images we want to fast
always see and need to be manipulated as well, may be flipped vertically, maybe shield a little bit
so that we can enhance our database without actually getting more data.
That's a way to do it if you get your data and try to manipulate the colors if the color is not important.
Manipulate the shape, the flip, the rotation.
If you have played all of this thing, what you are doing is you are enlarging your database in a healthy
way so that your model can learn better.
Now from Kiraz, that preprocessing.
We are going to import image now.
We also need the famous library, which is called Nonpoint.
Now, no, it is a math library that is very fast and used in Python.
It has actually the C programming language in its background.
So it's really fast because it is interacting almost directly with the hardware.
So a number is a great library format operations, and it's really recommended to always use numbers
when you are doing any math manipulation rather than using the Python Native Library for math of the
population.
So we're going to say import numbers as and now when I type this, as it means that instead of typing
non-pay every time I just type and.
OK, so you're going to see that later in the code.
Now we need also to encircle flows of import, denser flow as T.F..
So instead of typing dataflow every time, we just type here.
OK, so this is about the libraries that we need.
Now we are ready to stack all the convolutional next layer one by one in the sequential class.