In the last video, we used data augmentation techniques to increase our validation accuracy to a two
to two to three percent.
In this video, we will use BDD 16 model architecture to further increase our validation accuracy.
About 90 percent.
Viji, 16, was The Runner-Up of 2014.
I unless we are see competition.
The problem is statement of that competition was to categorize millions of pictures in two thousand
different categories.
The pictures were of animals, humans, et cetera.
And the categories were off different animal species and many other.
So the problem we are trying to solve.
You can consider it as a subset of all regional 2014.
Unless we see completion data.
As we discussed, in order to be lectured.
We can use convolutional part of this retrain model architectures of problems.
These murders consist of two parts, convolutional base and then a fully connected neural network base.
The convolutional base is used to identify features from the images and then.
The fully connected, neutral base is used to classify those features.
So for any similar kind of problem, we can easily use pre train convolutional base to extract features
from our images.
And then we can do three layers of fully connected neural network to classify the desert of this can.
Mrs..
In this video, the idea is same.
We will use the on base of Viji 16 modern.
And then we will add one fully connected hidden layer and one output layer to classify the features
extracted from what we do this extreme con base.
So let's start first.
We will be creating to object green generator and validation, you know, that we have already used
the same generators in previous cases also.
So we are using the same setting.
We are using these scaling off one by 255 to convert our RTG.
We will lose.
From zero to 255, two zero two one.
Then we have a rotation ringgits, which ship high chair Shearin zoom range and horizontal flip to create
dummy augmented data.
And our target sales of images is one 50 by one four feet.
And we are using a bed size of twenty.
We have already discussed this in detail in our previous videos.
So we are not going to discuss this here, just like in our previous case.
We have our own 2000 images.
For training and polls and images for validation.
Now, the second step was to create architecture for more than.
Now, our idea is to first use a corn base of disease 16 and then use to then slier.
So to use corn based off, we do this 16, you can directly import that from Kiraz.
There is no need to manually build all the corn layers in that base.
So the import we did is 60.
You can just right from then sort of flowed out, get out or the application import.
We do these 16.
And then give these three different parameters.
So we are creating our corn base object and we are using.
We did this.
And these are the three parameters that we are passing.
First, we need to provide Waites.
So in any convolutional neural network, first we provide randomise suite.
And then our convolutional network tries to optimize those words.
Since.
We do these 16 was used in that competition and we can use the final weights of that more than.
So to use those weights, we have to right weights equal to imagine that you made.
Net is the competition.
Yes, we are see competition.
So to use pre train weights, we just separate very quickly Metronet.
And then there were two parts of that.
We do these 16 model first for the corn based and then the fully connected Nuran liquid base.
We only won the corn base from that model since corn bases are reusable.
Those are mainly used to extract features and not to categorize the images.
So we will be only using the corn based and we only need to import corn based.
That's what we are using, include underscore top equal to falls.
If we want to impose the whole model, along with the fully connected, dense layers, then you have
to change it to cool.
But in our case, since we are on the importing the convolutional base, we are providing false here.
Then next parameter is to give the input chip.
The input shape of our images are one four feet by four feet by three.
That's why we operated this couple here.
Let's turn this.
So we have imported our corn base from which it is 16 model.
Now, to look at this, you can just write one based dot somebody's.
Oh, if you run this, you will get details of all the layers of this, which is this extreme corn base.
Now, as we discuss in order to re lecture.
We do these 16 have this convolutional blocks, so here you can see first convolutional block, then
second convolutional block in each block.
There are multiple layers.
So in first sense, I can blocks.
There are two corn layers.
And then a max pulling layer in third, fourth and fifth block.
There are three corn layers and then a mix pulling layer.
So in a way, by importing BGT 16, we avoided creating these many layers and we have already imported
the final Waites of that model.
So there is no need to randomly provide weights and optimize those words.
We already have the final more than weights with us in this part of.
Now, the next step is to add fully connected, dense layer and put layer in front of this fan base.
Now, this is similar to creating any CNN model.
We just have to create our model first.
We are using models, not sequential.
And then just like you add any other layer, you can add the corn base that we have imported.
So we will write more than not egg.
And here you can just write the variable in which we have is stored.
This video is 60.
So what we will need was on base.
So first we can add this one base.
Next, we have to use a flattened layer.
And then include a fully connected, dense layer.
And then output layer.
So first, we are heading deadlier than our dense layer with 256 neurons.
And then an output layer with a single neuron.
The activation is a loop in the dense layer.
And that tuition is sigmoid.
The output layer.
You can run this and then you can look at the more than somebody else.
So if you see this is over more than somebody, our first layer is we do do 16.
We have it on 14 millions re-enable barometer in this disease, 16 layer.
Then we have a flattened layer than we have a dense layer with around two million cranial parameters.
And then finally, an output layer with 257 cranial parameters, that totally trainable parameter.
And our model is that on 16 million.
Now, as I told you earlier, we were using the weights of the final.
We did the 16 model.
So the weights are already optimized.
In this, we do this extremely at.
Now, if you don't want to screen those weights, you can just freeze that layer.
To freeze that, you can use corn based, not trainable, equal to falls.
In that case, the cranial parameter here will turn to zero.
And our model will not try to optimize the weights of this layer in that way.
We can significantly reduce the number of animal parameters in one model and significantly improve our
execution.
So if you run this one based or trainable, equal to false, our number of cranial parameters will reduce
from 16 million to just two point one million.
But here we are not running this and we are screening all the sixteen million parameters.
But in case you want to save thing, you can run this corn based or cleanable equate to false.
Now, the next step is to come by lower Märta.
We will be using the lost function of Binary Cross and Groppi.
Since we have two classes, then we are using Artemus Prop as our optimizer and a learning rate of two
and two tameness were minus five.
We are using somewhat smaller learning rate to get just because we want to fine tune our already trained
model.
The roots of this convolutional lietz are already optimized.
And we just want to optimize it and little steps according to our problem.
So since we are fine tuning it, we are not draining it from randomly assigned weights.
We can use a smaller learning rate.
That's why we are using two in bootprint dendrites, four minus five.
And the metrics.
We want to calculate is of accuracy.
So screaming these models will take somewhere between eight to 10 hours.
So it is better to use callbacks who say you are more than offset each epoch.
We are creating our tech porn callback and we are saving our model for each people.
You can also use save best only barometer here if you don't want to save.
Different models.
And if you give safe, best equipped crew, we will save more than with the best value addition and
support.
Now, the next step is to fit the training data.
The step is similar to the last thing we will use for gen rigor and then Green Ritter with his Steps
Buddy book, and we also give validation and data and validation steps for evaluation data.
And yet we are also providing callback just to say, well, model after each epoch.
So I have already executed this.
And these are the results.
So if you see the validation, accuracy's, are in the range of 92, 97.
So at the end of the book we will getting our training accuracy of around 98 percent.
And the validation, accuracy of 98 percent as well.
You can see each epoch is taking around 15 minutes to train.
So just remember, this may take up to eight to 10 hours to Cremer.
What more than.
Now, let's look at how accuracy's and losses are changing with each people.
The audience line here is for training accuracy.
The red line here is for evaluation accuracy.
And similarly, we have evaluation loss in green and greening loss in blue.
You can see that validation accuracy is oscillating between 97, 98, and there is no further improvement
in accuracy as we move from lower Depok or a little higher.
So we can say that we have achieved a convergence in our model.
And it is not possible to further improve this validation accuracy with increasing number of epochs.
So if you compare the validation accuracy with our last CNN model, in the last CNN model, we were
getting the maximum accuracy of 84 percent.
But in this, by using BDD 16, retrain more than we are achieving up to 97, 98 percent of validation
accuracy.
And it is very easy to train our model using this retrained models.
So there is no need to create your own corn business.
You can just use any one on pre retrained corn basis.
If the problem is statement is somewhat similar to the image, net problem is statements.
Now, I am also saving this history variable and blowsy at Sufyan.
There is no need to do this.
A step here, Bill.
We were on legal, including the accuracy's on our validation sets.
But now it's time to use our tests to see how this model performs on our test site.
Now we have to follow the same steps to evaluate our model for performance.
Again, we will be using test generated.
So we're creating another generator.
We are calling this generator.
We are using the test and that's called detergent.
This is the same object we use for validation as well.
So hidden in this object, we are just reshaping our data from zero to 255 to zero to one.
And then we are using flow from barratry.
And here we are creating a static tree instead of validation category.
So we're testing it.
That is literally.
Now, normally, if we have data in the form of a data frame, we use it, well, you admitted.
But since we have our data flowing from our directory, that's why we have to use it.
Well.
It underscored generator.
So there is a simple back.
What we were using for generator.
Similarly for revaluate, we are using it will.
Your gender does.
And here also we have to provide a base generator object and the number of steps.
We have a bed size of 20.
We have to touch base data size of our own potent images.
That's why we need 50 steps.
Thousand divided by 20, equal to 50.
So we will be able to go our all our best images in four feet steps.
So if you run this just like evaluate method, you will get to use force as the lost value.
And second is the accuracy value.
And here you can see that the accuracy we are getting is little.
Ninety seven percent.
So just foodways.
We started with a simple, convolutional model.
At that time, we were getting accuracy off our own sound, 74 percent.
Then we use data augmentation techniques to create dummy data and avoid what fitting?
In that case, we were getting accuracy of our own 83 to 84 percent.
And in this case, we used up retrain.
We do these 16 more than.
For our problem and in this case, we are getting an accuracy of 97 percent.
So we have increased over valuation accuracy from 73 percent to 98 percent during this project.
That's all for this project.
Thank you.