Now, in the last part of this project, we're going to use a pre trained model, we just named Lee
Didi's 16.
This model was Binet of 2013 image that competition.
However, we now have more advanced architecture also.
But for this problem, we are going to consider a logged CNN model which was trained on imaging data
dataset.
This image dataset had one point four million labeled images and they were chosen different classes
in which images were to be classified image.
It contained animal glasses, different species of cats and dogs.
And does we expect this model to perform well on the cats versus dogs classification problem?
Also.
So we'll use this BDD 16 architecture.
This will delivered in 2014, and it is a simple and widely used, convolutional network architecture.
What image problem?
Although it is a little bit older and there are some really there are some advanced and somewhat heavier
recent mortals, this architecture will be easier to understand, and that is why we are going to use
this architecture of this particular problem.
Also, this is one of the connectors which comes prepackaged that get us.
So we did not load up the beaks of all dealers get us has these boots stored in it.
So let's see how they use these convolutional layers of this breathing model.
Again, I created a new project.
If you are working on the same project, you need not loaded.
Ready?
Get us.
And you'll need not create these directories again.
This is my new budget.
I went to do it.
Not to instantiate DVD 16 model are too loaded.
We use this application, understood.
We did 16 function.
This will load all the weight at all the cells in this PGD 16 architecture.
When it was trained on the image that does it, the other parameters that include top include top refers
to including or excluding the densely connected classifier.
On top of the network.
So as I told you, we Didi's 16 was actually used to classify images into tosing classes since.
And our problem.
We have only two classes.
The dentally connected list is not required.
So we'll have our own densely connected layer at the end of the model.
We are just going to use the convolutional part of this model.
Input chip parameter is an optional battery that we are telling that the images that we are going to
input are in this shape.
One could be very unhappy pixels the three channels.
However, if we do not give this input chip, it will still accept shapes of any dimensions.
So let's load the convolutional wake's.
Now, the.
Downloaded.
It took nearly five to six minutes for me.
Now, since the data is downloaded, we can look at how is this convolutional structured?
Let's run this.
And look at what does the architecture in this model.
We did you 16 is a big architecture.
We have already discussed the entire architecture in auto to relate to.
It takes in an input of 150 women, 50 by three.
This is the input that we have specified.
Then there is a convolutional block which is giving out 64 features.
Then there is another congressional led with 60 vote vetoes.
Then there is a pulling leg, which is doing up two by two pulling.
That is traducing height and weight, too.
Then there are two convolutional legs.
Again, a max pooling.
Then again, three convolutional layers with one max cooling.
Then three convolutional layers, one with max cooling.
And then there are three more commission layers with one max pooling.
So at the end of it, we have 512 features of four by four tails.
So it is a very small format for Matrix, with 512 features extracted.
Overall, there were fourteen point seven million parameters on the laptop that we use for day to day
work, running such a model would have been not possible.
That is why for routine jobs, using a preordering model makes more sense than to creating a new model
with so many bad and we just to be doing so.
In fact, if you are not running a DIPU system, training such a model would be not possible on a C
Bubis system.
Now this is only the convolutional base after the base.
We need to attach a fully connected classifier.
That is, there should be few layers of normal neural network.
And the final output layer should have only one neuron with a sigmoid activation function.
Telling us which binary class does that image belong to.
So the output of this convolutional base is flacking.
So we have a flattening led.
Then we have a hidden lair with 256 neurons
and activation function relu, the output of these 256 neurons goes into only one neuron.
And this neuron has a sigmoid activation function, which basically tells us the probability of belonging
to one class.
So we've done this also.
And our model is now the entire convolutional base, which is then, as we did, 16.
The three layers that we have added.
But noted that all these sixteen point eight million parameters are right now trainable parameters.
But we are going to do is we are going to fix the weight of the convolutional base.
We are not going to retrain the convolutional base.
We are assuming that the convolutional base of the BGT model, since it was also trained on a similar
to, say, which had got breeds and dog breeds.
And it was actually working on thousand different classes.
The kind of features that it was taking out of the images, the same features could be used to just
distinguish between cats and dogs.
So the idea is the congressional leaders are giving us the features, the same features which were identified
by Viji in image net dataset, the same features can be used for our Douglass's tax classify.
Those features will be input into our own neural network.
At the end.
And that neural network only has to be trained.
So to freeze these rates in the convolutional base, we use dysfunction.
Freeze.
Wait.
And when we done this debate of neurons in the convolutional base that is in this BDD 16 model, these
will be fixed.
It has fourteen point seven million parameters that were to retrain.
Now, if we look at our model, only these two million parameters remain, which are to retrain the
other fourteen point seven million parameters, which were part of BGT 16.
These are Tumnus non-criminal parameters.
These are fixed.
So that is all our model is really the architecture is set.
We just have to repeat whatever we did and now we have to train DTG, which will be giving images in
batches of 20.
He also doing the documentation that is new artificial images will be created by randomly changing these
parameters, giving it other Dacian of some degrees, shifting it by some pixels, zooming in those
coming out until on.
So this is what we did a little better than we import this thing, dodging into the train generator,
which will give us images in batches of 20.
Then we done this test data, which will only be scanned the test images by 250 feet.
And we use it in vegetation generator, which will do the same for ventilation images.
Then we compiled a model.
Compiling the same loss function is going to be binary cross entropy.
However, in the optimizer, which didn't have automats prop optimize it, but we are using a very small
learning rate in this model.
So earlier we had finished about minus faught as the learning rate.
Now we have reduced that even further to doing 210 but minus five.
This is because we want to take very small steps in the direction of optimum, the metric that we are
going to monitor.
That is accuracy.
So we compiled a model to know that one two have come by.
Do not test the architecture.
Otherwise, these parameters that we froze will not be frozen anymore.
So if you change the architecture, you have to freeze these parameters again and then compile again.
So compiling would be the last step before you bring your model.
Now we are going to train our model for this.
We are again going to use the train, Jeneda, which will input 20 training images, editing steps.
But Epoch is said 200, which means we are going to use 2000 images in one book.
Twenty.
Into one hundred.
So 2000 images.
But each book will be input.
For training, e-books is set to 30 model gain.
If we do not see the solution converging, we can run this model logging for more number of epochs.
Validation data is a validation data, which will again give validation images in batches of going deep.
Validation Steps is 50 because we are going to use 1000 images for validation purposes.
So, again, I'm going to warn you that it is very important that this will be done on your computer.
Only if your computer has sufficient computational power.
So if you're running tens of law on Deepu, all you have good RAM in your C.P.U.
Only then this model will be able to train.
Otherwise, it is going to take awfully lot of pain and you won't be able to get the results.
So only done.
If you have good computational power in your computer.