And welcome back.
What we're going to do now is we're going to actually use transfer learning by feature extraction,
which means that all we do is we freeze all the convolutional layers, all the first block of layers
and the network that we loaded and then just trained the top players.
So let's take a look and see how we do that.
So firstly, we load our net model here that we've done previously, and we set pre-trained equals true,
which means that we're loading the image net with here.
Then what we do, this is the part where we freeze the layers here.
So we set for the parameter of whatever we call this variable in the model convolutional parameters,
we can set the required ingredients here to be false.
This is this was what how we freeze layers in part to it.
So it's basically all the convolutional layers here in the network.
All the trouble is we're setting it to.
We're freezing them here effectively.
Next, what do we do?
We're going to create a fully connected layer here.
So we just take the model uploaded the convolutional layers of the resonant.
And we just take the fully connected features here, the last layer features, and then we add on to
our output output class here, basically.
So what this does, this is going to keep this is this these are the Trinamool is here.
So these are newly constructed modules and by default requires graphical true meaning that they're not
going to be frozen, they're going to be trainable at that point.
So we just passed this model to a GPUs set across them to be lost criterion.
And then we just use again or living with Cedillo along with us, took us to Gradient Descent Optimizer
and put these settings here for good.
And then let's just create that.
Actually, this wouldn't run right now because I am still training this model.
It's almost done.
Hopefully, by the end of this lesson, we'll have the results and then what you can do, you can just
finally just train that model.
Here you pass the mode that optimizes learning, which had you lose the model criterion.
And that's it.
And no one can take a look at her results.
And you can see again, it's a bit spiky.
We put up a ninety four point seven percent accuracy.
So that means that we're going to get that.
This model that's been returned here will be the best model unless there's some better results in this
25, and I don't see it.
So that's going to be the best model, and I don't have individualized predictions for those results
here generated so you can experiment and visualized out on your own.
All right.
So that's it for this lesson.
This is quite simple and actually do train most of my image classifiers in this method here by either
combination of transfer learning, which feature extraction or fine tuning by freezing different layers.
It's very good to experiment with freezing different layers and PyTorch and seeing how it affects the
results on your dataset.
So I hope you enjoyed it and we'll stop there for now and then.
Next, we'll continue with using a pre trained model as a as a feature extractor like we just did.
However, instead of having a fully connected neural network on top, we're going to use a linear network
like a logistic regression to use the inputs from our previous layer as inputs to that model.
And then and then create a model out of that.
So I'll see you in the next lesson.
Thank you.