Now the next step is to cleared the structure of what CNN more
for this we will for this problem.
We will be using four different kinds of layers with Max pooling.
And after that we will apply our dense layer and then an output Nero so for our first layer we will
have one layer with 32 feeders and three by three window.
And our input sizes 150 by 150 by 3.
Remember we mentioned our target size.
While data processing as one for pick was one of these.
And since this images are colored images we have added we will lose.
That's why we are providing a third dimension as three after this.
We want the max pooling layer here.
We will use a window of two way too.
After this we will use another layer with six to 44 years and three by three window.
Then another willingly then we will use another con layer with 128 features and add another pooling
layer of the White tool window then we will have another layer of 128 filters and a pooling there with
two by two window
then we will use like ten and then a single dense layer with five and value at all and then a single
output layer with one neuron.
Since we would only want to predict two glasses
one important thing here is to know the number of features that we are using.
You can see as we are going on in our network we are increasing the number of four years and now what
can layer.
So this is a general practice with each cone layer.
You have to double the number of filters.
You are going to use and another important thing is that if you remember the max pool of window 2 way
to you at reducing the size of fewer images.
So if you have a image of 150 by 150 after Max bullying you will have a major of 75 but 75 so after
this is step off that this layer we will have images in the dimension of zone divide by 70 feet.
Then after this another Max pulling we will have images of 37 by 37.
Then after this we will have images of 18 by 18 and then 9 by 9 so if you see the number of features
are increasing as we go along on our network and the work and the lens of forward images are decreasing.
This is a standard practice.
You are image size should decrease with each one layer and the feature map height should increase as
you go along the network.
So this is the structure we are following for this problem let's just run this
another thing is that earlier we were using guitars got laid.
So now we have important layers and we don't have to put guitars or layers and so on.
So another little thing
let's look at somebody.
You can see we have four can layer with four different pooling layers and then a dense layer and then
output layer the total number of parameters that we are creating in our model is that on three million
now.
The next step is to compile the model.
And this time instead of using as Zilly we are going to use Adam's prop
Adam's prop.
Have a little advantage or as Julie while performing image processing.
That's why we are going to use Adam's prop.
And here we have also mentioned the learning rate of zero point zero 0 1 by default.
The learning rate is point 0 1 and we have mentioned the learning date of zero point 0 0 1 7 this
now.
The next step is to fit training data in our model and earlier we were using model load fit but now
since we have data in the form of green generator we are getting our data in the batches of 20 directly
from our directory.
That's why instead of using dot fake we are going to use dot generated for using image data generated
as our input.
We have to use for dinner.
The process is almost same instead of DOT fed.
You have to use dot underscore the data then then you have to provide the object that is generating
the data.
In our case that is green generator that we have created earlier.
Now now another difference is that this train generator is generating data continuously.
So we have to mention this stopping point and we are mentioning the stopping point in the form of number
of steps.
As you remember here while creating our train generator we mentioned that the bed size should be of
20.
So this train generator is generating data in the packets of 20 images.
Now our crane dataset is of 2000 images so how many steps are required to cover all that to hold on
the steps.
That is 2000 divided by the number of images in each bet which is 20.
So that's where we want under step in the hundreds of steps we are going to cover all the 2000 images
that we have in our train directory.
So just remember to use the steps but epoch barometer.
And this you should go away by dividing the total number of images that you have by the number of images
you have in your each batch.
So 2000 divided by 20 equally 200.
We want to create this model for 20 bucks.
That's why we are providing box equal to 20 and similar to fate.
We can provide our validation data as well here the validation data is in the form of validation and
data.
We have created validation generated Aliyah and here also we are using a bed size of 20 and in our validation
formula we have it on poles and may images so tall then divided by 20.
We need to run this for steps.
So we have to provide validation additional steps equally 250
let's run this.
So if you see this is very similar to fake function and fake function will directly provide the data
here and set off providing data directly we are providing a generator that is generating the data and
we are mentioning the steps or the limit on the number of times that generator is going to generate
the data.
So the training may take several minutes.
So I am skipping the training part.