‫All righty.
‫So we've got a tense board call back, which is going to help us monitor our model's performance as
‫it's training.
‫So figuring out if it's learning correctly, is it doing well or not?
‫Now let's create an early stop and callback.
‫Early stopping helps prevent overfitting.
‫So our model learning the training data too well by stopping a model when a certain evaluation metric
‫stops improving.
‫So if a model trains for too long, it can actually do so well at finding patterns in a certain data
‫set that it's not able to use those patterns on another data set.
‫So it doesn't generalize well.
‫So if we come back to our exam.
‫If you were to learn the course materials far too well like you learnt them off by heart.
‫AK.
‫If you're in university and you studied way too hard on the course materials, you've memorized them
‫off by heart.
‫When you come to a a practice exam or a final exam with questions that you haven't seen before.
‫If you've memorized everything on here, instead of just learning the inherent problem solving patterns
‫of the course materials, you're not going to do very well on the practice exam or the final exam,
‫so you're not going to be able to generalize very well.
‫And so early stopping helps prevent our model from overfitting the course materials, a.k.a. the training
‫set, so that when it comes to a data set that our model hasn't seen before, it's able to perform well.
‫Let's see it in action.
‫We'll create an early stopping callback.
‫We'll go here like this.
‫Early stopping callback and we'll change that to mock down.
‫Wonderful.
‫And so if we go up here, we could go TensorFlow, carer's, early stopping callback.
‫And this should take us to the documentation.
‫There we go.
‫Early stopping.
‫So that's what you can check out there.
‫Stop training when a monitored quantity has stopped improving.
‫Let's do that.
‫Might just link this in here.
‫Why not?
‫A beautiful and we'll write a little note here.
‫Early stopping helps stop our model from overfitting by stopping training if a certain evaluation metric
‫stops improving.
‫So to set up early stopping is pretty simple.
‫So we'll go create early stopping callback and we'll go early stopping equals TF Carer's callbacks and
‫early stopping.
‫Wonderful and we want it to monitor.
‫So this is the parameters.
‫We pass it to you by default.
‫It monitors the validation loss.
‫So we're going to see this in a second when we run a model, but we might choose validation, accuracy,
‫and now you could choose validation loss if you want.
‫But we're going to choose validation accuracy and we're going to give it a patient's value of three.
‫What is patient's number of epochs with no improvement, after which training will be stopped?
‫Hmm.
‫What's an epoch?
‫Well, let's figure that out in the next video.
‫I think so.
‫We'll just run this.
‫These are going to make these callbacks as well as this model function.
‫I'm going to make a lot more sense once we start training a model.
‫So that's how early stopping callback ready.
‫We're going to monitor the validation accuracy.
‫As soon as it stops improving for three epochs, we're going to stop training our model.
‫So in the next couple of videos, what we might do is I think we are definitely well and truly ready
‫to start training a model.
‫So if we come back to our keynote, what we're focused on, we've picked a model from TensorFlow to
‫suit our TensorFlow hub to suit our problem.
‫We've turned our data into tenses.
‫Now it's time to fit a model to the training data and make a prediction.
‫So how about we make a function for training a model?