‫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 to forecast
‫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 mean.
‫So if we look here, what's the first layer?
‫It's going to run from top to bottom.
‫And here we go.
‫Here's another collab error.
‫You might see this.
‫Hopefully it fixes itself.
‫Otherwise we can fix that later.
‫The first layer is hubcap layer.
‫Model URL.
‫What this is saying is it's telling tensorflow hub to create a carer's layer.
‫So what we're doing is we're using carers to build our deep learning model.
‫It's telling it to create a carer's layer of model URL, which is our mobile NAT V2 architecture.
‫So you might be wondering what's going on with mobile net veto.
‫And why do we only have two layers?
‫Well, let's check that out.
‫Let's go.
‫Mobile net V2 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've found a model from TensorFlow hub, or maybe I've seen a tutorial or using some sort of model.
‫I'm trying to figure out what's happening.
‫So we got mobile network to convolutional blocks.
‫Now, if you wanted to check out that, you might want to look up.
‫This is com is 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 type 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 keynote, we've prepared our inputs and we're passing it to the machine learning
‫algorithm, in our case, mobile net v2, and it's going to 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 and 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 v two, 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 1280.
‫So that's the last layer.
‫And now you'll see this overall architecture and in papers and whatnot.
‫Hopefully, if they're a good paper, they've included this and if there are any 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 numpy.
‫So if we go outputs equals np let's just do ones of shape equals one one 1280.
‫And then outputs.
‫So it's just going to be a long list of different numbers.
‫But 1280, we don't actually need that.
‫Right.
‫This is where our dense layer comes in.
‫This is where our output come in.
‫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 two is going to go through for us and find all the patterns and then condense them into one
‫long array of numbers.
‫1280 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, hey, actually, instead of that 1280, we want our output to be in the shape
‫of however many labels we have.
‫And you might be wondering now.
‫Okay.
‫What does dance do?
‫Let's look at the docstring.
‫Just your regular densely connected MN layer.
‫Well, thanks docstring.
‫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 Macs?
‫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 self max, each component will be the interval zero one and the components will add up
‫to one.
‫Now we will see this later on, but that's all you have to know for now.
‫And if you're wondering what soft Macs 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 multiclass classification, the activation is soft max.
‫Soft Max.
‫So that is what is happening in here.
‫We're creating a carers model.
‫It's going to run in sequential fashion.
‫The first layer it's going to call is the model URL, which is actually the mobile net V two architecture
‫which has been implemented for us.
‫And within that mobile net V two, architecture is going to be a series of convolutions.
‫What you're going to find patterns in our input images and learn the features of those images.
‫If you're wondering what a feature is, let'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
‫1280 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 sof max to convert those patterns into numbers between zero and
‫one 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.