So congratulations, you've just trained your first CNN network and by thoughts.
And you can see the accuracy is quite good.
Ninety seven point eighty eight percent.
However, after seeing that score, what what can we do now?
It feels a bit underwhelming in a way that we've created a school network that does this.
But can we actually see it work?
How do we input data into it and how do we re-use this model in future?
So that's what we talk about this function called torture.
Don't save.
Now what we do.
This allows us to save the model wins because remember the way sort of gradients of the model that we
trained, that's essentially the model itself.
It is, actually.
So once we have the model structure, we can load those weights back into another set of good or in
a different computer anywhere you want.
So you just need a weights file and a model structure, and you can basically recreate your network
and use it in any way you want.
Make it portable.
So to use torture to save all we do.
Just specify a part here.
This part can be directly pasted into here if you wanted.
This is what I'm calling this model name.
I'm calling it Amnesty, underscore CNN on the score net dot edge.
That's the Python Watch model with its file.
Usually the file or file, but can work.
So to see if we used to watch Dot ceive open brackets.
Net Dot Stick.
That's basically gives the dictionary format of the width so close by to which are constructed in what
weights in the relevant places and specified the part.
And that's it.
So if we run this, which I'll run for you guys here, you'll see this is a file here.
If you wanted to download it for sentimental value, if you want to use it on your own PC, just download
this network.
It's pretty quick.
And there we go.
So we do have downloaded your first model that you trimmed, so we'll take a look at how we can use
that afterward.
But for now, let's take a look at something even cooler.
Let's let's take a look at basically running some tests, getting some.
First of all, let's get some test images out.
What I'm going to do for you is I'm sorry for confusing in this lesson.
I thought this was something else.
What we're going to do now, we're going to take a look at some of the test data and then run that test
data to our model and see what what the model outputs.
Because remember, we were getting ninety seven point.
What was it?
Point eighty eight percent accuracy, which means it should pretty much get everything right.
Most things right.
So let's take a look at this.
So let's display isn't the torch vision?
Utilize some of our test data here.
This is the ground truth labels for it.
And this is our grid of images.
This is zoom in for you guys.
Now let's reload or reload the model.
We just see it.
So to do that, we have to create an instance of the model and move it to operations in memory and operations
to the device.
So we do that there.
We just created the net.
That's the class again.
And that object.
This time it's creating a new blank model doesn't have the weeds yet, sending the model to the GBU.
Then we load using load undisclosed.
It underscored that we lowered the PI torch model we just received, and that basically puts the weights
onto the model.
So we basically have the model that we just create by just running the simple line of code here.
So now let's see how we can get some predictions out of it.
So some of this quarter should look familiar to you.
OK.
Remember, we created to iterate, iterate over for a test later so we can get our test data here.
We use test views, a dot next function in Python to get to labels and images out of it.
That's the first batch.
Then we move it to the CPU.
Do you know why this should look familiar to you?
This is what we've been doing in the training loop that scroll up to it over and over.
We did it here to get the predictions of the test data, and we did it here during the training.
So why are we doing that for?
Well, let's go back to it.
What we're doing here, we're basically taking some of the test data, feeding it to a model by just
putting the images here, getting the outputs, getting the class probabilities biggest using torchlight
max.
The reason we use it to watch MAX function that gives us basically the class.
I had the maximum probability score out of it.
We use, we get it in the predicted variable here and then what we can do, we can just see the predictions
displayed when using a list comprehension here to access it.
Maybe I didn't mention this previously, but we will have to send it to the CPU and send it to number
to printed out.
It's just easier way to do it the other way.
In the many ways you can do this.
This is a way that I find it's quite quite simple and easy to access to values here.
So 4G in this range here at.
128.
We get all of the values, predictive values from this predicted intensity here.
So these are the values had predicted seven two one zero four one.
Let's take a look at our image here.
Seven to oh sorry, it's one zero one zero four one four nine.
Yeah, it was.
So this is pretty cool.
There's another way I'll show you how to display these results in a much nicer format.
But let's take a look at something else here.
Remember, this was the part of the loop where we took home, where we display the accuracy.
So if we just extracted, that could.
From here, you can see what to watch Nevada, which is why we run inference in our model.
We just take the little order here.
We get the data out of it, move it to the GPU, passage in a network, get the predicted outputs,
then get the accumulated total and correct how much is predicted correct here by using this function.
This line here, and we just said these are basically the accumulators.
That's why we set them to zero initially.
So we can keep getting how much, how much it did, how much data, because this is going to be dollars
in the end.
And this is going to be some value nine, seven point eighty seven.
So it's pretty cool.
Then we just get the accuracy out of it so we can display as simply the accuracy out here as well,
and we can set how much significant digits we wanted.
So let's take a look at something else.
Let's take a look at plotting what training looks.
So I'll stop there and we'll go through this section afterwards.
So thank you, and I'll stay tuned for the next section.