Now we've got a beautiful function to create a model for us and we've actually used it already we've
instantiated a model and got the summary.
You might be looking at this like what's going on here.
Even looking at this like what's going on here.
So let's go through this step by step and figure out what's actually happening.
So first of all we instantiate a model so set up the model layers by using model equals t after a crystal
sequential.
What's happening here.
A linear stack of layers.
So when it says that what it actually means is it's just a stack of layers.
That's going to take some sort of input find patterns in that input and then have some sort of output.
That's what the linear stack of layers make.
So if we look here what's the first layer it's going to run from top to bottom.
Here we go.
Here's another collab era.
You might see this hopefully it fixes itself.
Otherwise we can fix it later the first layer is hub carers layer model U.R.L. what this is saying is
it's telling tensor flow hub to create a carer's layer.
So what we're doing is we're using carers to build out deep learning model it's telling it to create
a carer's layer of model U.R.L. which is our mobile Net V2 architecture so you might be wondering what's
going on with mobile Net V2 and what do we and they have two layers.
Well let's check that out.
Let's go mobile net the two architecture
so here we go review mobile Net V2 lightweight model image classification.
So this is what I do when I'm trying to figure out what's going on with a model that I'm using maybe
I found a model from tensor flow Harb or maybe I've seen a tutorial or using some sort of model I'm
trying to figure out what's happening.
So we've got mobile Net V2 convolution or blocks.
Now if you wanted to check out that you might want to look up.
This is com short for convolution so you might want to go what is convolution no network
so I'll leave a great resource for you to check that out but here's essentially what's happening.
That's a good image actually
oh another medium article beautiful.
So here's what's happening.
We have an input image and then mobile Net V2 has a whole bunch of these top of layers built into it
so they're going to look at the input image do some data transformations on it and then output it to
something a.k.a. a list of numbers.
So this is what our job is if we come back to the Kino we've prepared our inputs and we're passing it
to the machine learning algorithm in our case my net V2 and it's gonna output something so the beautiful
thing about transfer learning is that all of these parts are taken care of for us using mobile Net V2
we've defined our inputs and this is what we want at the end some sort of output.
Now let's come back to this review of mobile Net V2 and it's okay if you don't fully understand about
what's going on on here.
This is part of the experimentation of deep learning machine learning it's figuring out what's going
on what is happening to our data when we transform it our first focus is to always write working code
and then figure out what's happening after that if we want to dive deeper we can so the overall architecture
of mobile Net V2 it takes an input of size 224 squared times three a.k.a. the height and width of our
images times color channels it does a whole bunch of transformations so takes this input does transformations
like this okay.
And then finally it's going to output a single list of numbers that are a size of 12 one hundred and
eighty so that's the last layer and now you'll see this overall architecture and in papers and whatnot
hopefully they for their good paper they've included this and if they're in the better paper that included
code and you'll see this and you'll be wondering what is this.
Well it's something like this again you'll be wondering what is this.
So let's have a look what it might look like in num pi.
So if we go outputs equals NPV let's just do ones of shape equals one one twelve eighty and then outputs
so it's just going to be a long list of different numbers but 12 80.
We don't actually need that.
This is where our dense light comes in.
This is where our output is coming.
We want our outputs in the form or in the shape of 120 because that's how many labels we have so let's
put this all together.
We have an input of an image mobile Net v2 is going to go through for us and find all the patterns and
then condense them into one long array of numbers twelve hundred and eighty long.
But then this is a beautiful thing about transfer learning is because all of this has been implemented
for us all we have to do is say hi.
Actually instead of that 12 80 we want our output to be in the shape of however many labels we have
and you might be wondering now Okay what is dance do.
Let's look at the dock strength just you regulate density connected and then layer.
Well thanks Doc string that actually doesn't make too much sense but you might be wondering what the
activation is now Soph.
Max let's check that out.
What is soft Max.
And this is where you're going to get a whole bunch of mathematical jargon but let's just go to Wikipedia
now if you read that first line it might sound pretty confusing to you unless you've got a mathematics
degree or something like that.
But the main thing here is that after applying soft Max each component will be the interval 0 1 and
the components will add up to 1.
Now we will see this later on but that's all you have to know for now.
And if you're wondering what soft Max do I use which activation which lost function.
If we're working with binary classification the activation function is sigmoid.
So we come here sigmoid and if we're working with multi class classification the activation is soft
Max soft Max so that is what is happening in here we're creating a carer's model it's going to run in
sequential fashion the first layer it's gonna call is the model U.R.L. which is actually the mobile
Net V2 architecture which has been implemented for us and within that mobile Net V2 architecture is
going to be a series of convolutions which are going to find patterns in our input images and learn
the features of those images.
If you're wondering what a feature is that's come up to an image.
Let's take this one for example a convolution may look at each pixel in this image and go okay.
There's a vertical line there's a circle here there's a circle here there's a horizontal line here.
Now the thing is we don't tell the model which of these features it learns it figures them out on its
own so that's the important takeaway there.
That's the whole premise of machine learning is that it figures out the patterns in these images for
us.
So we come back.
So once it's gone through the mobile Net V2 architecture it's going to output a single array of size
12 80 with all of the patterns it's learned in an image.
But we want to tell hey we want to go.
No we don't need 180 patterns.
We need 120 and then we want to use the activation soft Max to convert those patterns into numbers between
0 and 1 and then the highest number.
So all of the outputs.
So it'll be an array of 120 all of those will add up to one and the highest value is which one is our
label.
Now that was a lot to take in but we're going to over the next few videos break this down even more
so in the next one we're going to go through what's happening when we compile a model.
So I'll see you there.