‫In the last video we broke down.
‫What's going on here?
‫What we're doing is essentially just passing Kerry's sequential model.
‫An input a.k.a our image of a dog and then mobile net v2 a.k.a.
‫This model URL that we're using is going to find the patterns inside it.
‫And then we're going, Hey, no, we don't want the same shape as mobile v two.
‫We'd rather convert it to the size of our own output shape, which is the amount of labels that we have
‫with the amount of unique labels that we have.
‫So now let's talk about what's going on in compile O and by the way.
‫If you do want to dive deeper on any of this, I encourage you to search it up and figure it out and
‫try out yourself.
‫We're going to see the outputs of this later on.
‫So we're going to actually see the code running.
‫But whenever you look up something and try to figure it out, even if you don't understand it the first
‫time, trying to figure things out for yourself is a way to really cement your knowledge.
‫So if anything here you want to look up and find more.
‫Don't be afraid to ask a question and don't be afraid to look it up and check it out.
‫What's going on behind the scenes for yourself now?
‫What is happening with Model Compile?
‫This is something else you'll see when we're building a model with carers and so I think this one is
‫best explained with a story.
‫Let's say you're at the International Hill descending championships.
‫That's right.
‫You're one of the world's best at going down hills.
‫And you start standing on the top of a hill, and now your goal is to get to the bottom of the hill.
‫But the catch is that you're blindfolded.
‫And luckily, your friend Adam is standing at the bottom of the hill shouting instructions at you on
‫how to get down.
‫And at the bottom of the hill, there's a judge evaluating how well you're doing.
‫They know where you need to end up.
‫So they compare how you're doing to where you're supposed to be.
‫And their comparison is how you get scored.
‫Okay.
‫Your accuracy at getting down the hill.
‫You might be wondering, Daniel, why am I at the International Hill Descending Championships?
‫Well, let me break it down.
‫This is where the model compile comes into play.
‫Let's turn it into this terminology, because this can seem very confusing when you first begin.
‫So the loss so the loss is the height of the hill.
‫Now, our model's goal is to minimize the loss, getting it to zero, a.k.a getting to the bottom of
‫the hill.
‫So this means that the model is learning perfectly.
‫Loss is a measure of when the model is learning.
‫So when it's going through.
‫The training set and comparing the image to a label.
‫The loss is a measure of how well the model is guessing.
‫So when it's trying to make a prediction whilst it's learning, the higher the loss, the worse the
‫prediction is.
‫So the worse the model is learning patterns, the lower the loss, the better the model is.
‫Learning patterns, just like you.
‫If you're descending the hill, the higher you are on the hill.
‫At the International Hill Descending Championships, the higher you are, the worse off you're doing.
‫So your goal is to get to the bottom of the hill.
‫And now if we come back, let's discuss what the optimizer is in our Hill story.
‫So your friend Adam at the bottom of the hill, who's telling you how to get down the hill is the optimizer.
‫He is the one telling you how to navigate the hill, a.k.a. lower the loss function.
‫So how high you are on the hill?
‫Because he can see what's going on.
‫He can see your movements.
‫So he's basing his instructions on what you've done so far.
‫And now his name is Adam.
‫Your friend's name is Adam because the Adam Optimizer.
‫Yes, it's actually called the Adam Optimizer is a great General Optimizer, which performs well on
‫most models.
‫So if we have a look at this, we go.
‫Adam Optimizer.
‫Adam The latest trends in deep learning general and introduction for Adam optimization and if we go
‫machine learning model optimizes.
‫It's going to tell us.
‫A few more types of optimization algorithms.
‫So this is what's going on here.
‫The loss function is how high you are on the Hill.
‫You're trying to minimize that because you're at the International Hill Descent Championships.
‫The Optimizer is your friend Adam at the bottom.
‫You could also use another optimizer called RMBS prop or stochastic gradient descent, but generally
‫to begin with, Adam is pretty good on most problems.
‫So Adam's telling you how to get down the hill because remember, you're blindfolded.
‫You're a model who's going through the training data for the first time and trying to learn patterns
‫or trying to go down the bottom of the hill for the first time blindfolded.
‫And then finally, the metrics here.
‫This is the onlooker at the bottom of the hill.
‫This is the judge of how well your performance is at the bottom of the hill, telling you how you're
‫going at the championship.
‫So in our case, it's giving us the accuracy of how well our model is predicting the correct image label.
‫Who?
‫So that's a fair bit to go through.
‫But these are three parts of most deep learning models.
‫Basically, all of them you're going to have some sort of loss function.
‫So how well your model is guessing you're going to have an optimizer function.
‫So a function that helps your model improve its guesses and then a metric which is a way of evaluating
‫those guesses after it's learned.
‫So this is a step that we're going to have to take with when we're building any carer's, deep learning
‫model.
‫We define the model as some sort of layers, and then we define how the model is going to learn.
‫So hold on to that little story.
‫If you have any questions about the story or if you want to figure out what loss function you want to
‫use, search up something like what loss function should I use?
‫How to choose loss functions when training deep learning models.
‫Beautiful.
‫This is a great resource.
‫Or it might be.
‫I'll leave a resource there.
‫How you can choose a lost function.
‫But mostly it's going to depend on what problem you're dealing with.
‫So if you're using binary classification A.K.A, if you're predicting whether something is one thing
‫or another, such as images of cats or dogs, you would want to change your activation function.
‫To Sigmoid and then your loss function to binary cross entropy.
‫So we change this.
‫To binary cross entropy.
‫But because we're doing multi class, we keep it at categorical cross entropy because if we come here
‫multiclass classification activation, soft max loss, categorical cross entropy.
‫Now this is a lot to take on, so don't worry if you don't get it to begin with.
‫But remember the Hills story.
‫Remember what the loss is.
‫Remember what the optimizer is.
‫Just your friend Adam telling you how to walk down the hill and the matrix.
‫You could use a bunch of different metrics here.
‫So if we go here to Carer's Matrix.
‫It's going to tell you some metrics that you can use accuracy as the default one for classification,
‫but we've got area under the curve.
‫Categorical accuracy.
‫A whole bunch, Maine.
‫Precision recall.
‫So a whole bunch of different options.
‫I'll be sure to link those as well, but that we've gone through what compiling the model does.
‫And then finally we can finish off with this one because building, I think you can imagine what's happening
‫here is just another little way to say, hey, this is the input shape we're going to take to our model.
‫So we're using a carer's layer from TensorFlow hub.
‫And if we come back to here, it says that if we want to use this layer, we set up a sequential model
‫and then build the model with our input shape.
‫And it's this shape because that is the size of images that mobile net V two was trained on.
‫All right.
‫Now that has been enough talking.
‫We've broken down what our create model function does.
‫If you have any questions, be sure to leave it in the question and answer or in the Discord Chat.
‫But let's have a look at what's going on.
‫Well, probably actually in the next video, just quickly debrief what's going on in summary.
‫But the next thing we want to do is create some callbacks for our model.
‫So while our model is training, callbacks are going to be some functions that are going to implement
‫a few little helpful things that our model can do while it's learning patterns in the data.
‫So I'll see you in the next video.