Hi and welcome back in this lesson, we'll take a look at implementing the same rank one rank five accuracy
metric using carrots, so open that notebook and we'll get started.
If so, then that's what we're going to test in is to mobile on that level at V2.
So let's look at this network, and there we go.
So we've loaded the network we see it's 3.5 million parameters.
Not too big.
Not, but actually it's pretty small, to be fair.
Now let's download our image, net classes and our images.
Actually, we don't need the image.
No classes with two cameras, so this code is minus redundant.
And let's just get images here.
So I've actually downloaded these images previously, even just testing this notebook beforehand.
So I need to rewrite and overwrite all of his images.
So those images are stored in the directory.
You've seen the full images class one.
All of the images are here, so let's just get the file names out of it now because we're going to look
through all of those.
So what do we do here?
I don't make it function like I didn't fight too much.
Maybe I was a bit lazy when I was making this example code here.
But anyway, it's fine.
It's this experimental teaching code.
So what we do here, we're just looking through the file names here and then inputting them into the
a smaller model, which is the mobile net model that we created.
And we just create this this this open TV version of the image to display when you want to display it.
We get a model actually visited.
The Zespri possesses it here.
Then here's where we pass it.
Through the model, we use the decode predictions function that is specific to the mobile net class,
which you can see up here.
It's just double check that if it is specific to the mobile on the School V2 network.
So we have secret predictions and pre-processing function that's specific to that network.
Let's go back to it here.
So we decode the predictions stored in subclasses that we get.
We can setup equal five.
So that's similar to the function we use and play touch so we can set this to anything we want.
So if you want to get to the top, end or top, whatever, you just change this variable here.
So this is just giving us now the predictions and the top story, the top predictions for each of the
classes.
So let's run this and I'll show you the output.
So there we go.
So you can see for the basketball image, it returns an area that looks like this, so we have the tuple
and the fist as a fist in the first index slot of this array.
So it has the it has basically a number of specific to that which we wouldn't use its numbers.
This number is specific to the iteration of that prediction.
So ignore it for now.
Then we have basketball as a class and the Pro Bowl.
Two percent ninety nine point nine.
Very good.
Then we have rugby board very little percent.
Croquet will very, very little percent and so on.
And imagine all year the classes are super low.
It's very confident that this is a basketball that's good to know.
Now you can see it's for German Shepherd.
Ninety five percent limousine.
Ninety six percent spiderweb a bit less sure.
At 77 percent, pretty sure it's a burrito now that gives a lot of buzz buzz as the top class for this.
However, you do see Big Glass as one of the top five.
That's quite good.
That's one of the things.
It's a wallet miracle because of the shape, but it's a really a doormat.
Christmas stocking was 81 percent quite good and Collie was in eight percent, which is actually very
good.
So that's how we get the top classes out of that.
So you can see by looking at that predictions variable, these are the outputs here, which we just
display at the title of the subplot here.
We're just getting the top one out of the deal and we can see all the top classes, which is the top
five for each one is stored here.
So we have Rambouillet returns five answers for each image.
These are the five answers here, so it's a bit messy in the display, but this is a test German shepherd
limousine.
Some are printed in multiple and some of them seem lame.
So hopefully you understand what this is and know we have a growing with labels which we set here,
and then we create our own get school function where we use in here to get the number of classes in
the label.
So let's run this and what we'll do, actually, because I should have warned you earlier, but for
now, what we because we're using the predictions out of this here.
Let's set this to 10.
So we always have 10 top 10 predictions for each image in January, and that's why it becomes much smaller.
So apologies for that.
But now you can see this remains the same, but this now will get a lot bigger because as we're seeing
all the top 10 results for each image, and the reason why I do that for is because this get school
function, it uses that all top class as variable as as input here and we just set in here in this function.
But this function does not control the number of classes, but that was done in the loop with the Keros
top function.
So let's get the top five ranked five accuracy, which we saw was 7.7 percent, which is OK.
It's not about from mobile that Iraq won accuracy is pretty bad to its 55 percent accuracy, and now
we can see the rank and accuracy also at seventy seven point eight percent.
So that's not bad.
Overall, it's not great, but that's how we're rank top five.
What rank and accuracy using us if you wanted to use this on your own but never works?
Take a look at the code.
Take a look at the building blocks of this code, and you can easily just recreate it for your own network.
So I'll stop there.
And now we'll move on to where you're going to train, whether cats with dogs.
Listen here.
And the point of this lesson is to show you how you can actually train on your own data sets, as opposed
to the loading datasets from the functions and carers and page, which we're now going to download or
data said and trained on our own images.
So it's a good lesson for you guys to start learning with and also with the carers lesson, and we will
introduce callbacks as well.
So I'll see you in that lesson.
Thank you.