Now, as usual, we just copy this and then we could check out on this documentation for the significance
of each and every one of these arguments.
Here we have the file path.
So this is the file is where we are going to be saving our model.
So here we have our checkpoint called back and that's it.
We have model checkpoint here.
We're going to define this file path.
And then what are we going to be monitoring?
We're going to be monitoring the validation list, which is what is given to us by default, just like
with the URL is stopping where we had this monitor right here.
We are going to look at our validation laws and suppose we have this validation loss and then our training
loss.
So we're going to look at our validation loss, which is this, and then save the model weights when
we have this minimal or the smallest validation loss right here.
And then if you set the safe best only to true, then we'll save only these weights, whereas one is
false, we'll save this and also save the latest weights.
And then for this argument, save weights only if it's saved to if it's set to true, then we're going
to save only the weights.
Whereas if it's set to false, then we're going to be saving a model that has a full model with its
parameters.
Then we have the mode which is automatic, like since it's validation loss, since it's a loss automatically,
this would be a mean.
Whereas if this is an accuracy or precision, we're going to have a max right here.
So let's take this back to auto and then we have validation loss.
Now to say frequency when set to epoch simply means we're going to do this saving after each and every
epoch that we could modify this to say three.
So after three epochs we are going to verify if our current model is the best of all the previous models.
That's if we've set this to true.
So if we set this to true, we're going to verify if this model, the current model, is the best.
If it's the best, then we override this file path that's overwrite the file, the weight file we've
saved, and if it's not the best, we continue training.
So that said, let's modify our file path and then let's call this check points.
That's it.
So we have this check points and then we run this.
So we have that and then we add this callback right here.
So we have the checkpoint, checkpoint callback.
And let's find we run the training now and see what we get.
After training for over ten epochs, we have this two locks, which you could notice here, this one
where we've been told assets written to checkpoints, assets so you could open up this checkpoint here
and then you'll see that we actually saving this model.
And then we also have this locked here.
That's after the CID epoch.
Now, let's understand why this login is done after the first and also after the seed epoch.
Just when training starts, we have a validation loss of 0.47.
And so we supposing that since this is the first then the model such is best state, then it moves to
one which is greater than this.
So the model state or the best state is this one after the first epoch, this the model, the first
epoch or the model state are the first epoch is to the best.
This doesn't beat the record.
This doesn't.
And then you'll see that here we have this validation loss of 0.24.
That is why the model is now saved from this model check point and section will look at the reduced
learning rate on plateau and then later on we'll have a dedicated section for TensorFlow.
But the way it is learning rate are rather reduce learning rate on plateau works is that if you start
training with a fixed learning rate and then say you've trained for over 100 epochs and that the model
performance after 110 epochs.
So let's say we have 110 right here.
So after this 110 epochs, our model model performance doesn't improve.
So we still fix our learning rate, but since for the past.
Ten epochs.
We haven't had an improvement in the model's performance.
What we'll do is we'll reduce the model's learning rate by a given factor.
So here is the factor.
The patients our patients here is 10 million that we're going to wait for ten epochs before deciding
whether we're going to reduce the learning rate or not.
The verbosity, as usual, the quantity to be monitored.
In this case, the default is the validation loss, the mode automatic.
So if you wanted to be mean, you could specify mean or max.
But setting it to automatic allows TensorFlow to automatically decide whether it's a mean or max.
In the case of validation loss, obviously it's going to be a mean since our aim is to reduce the validation
loss as much as we can.
Then we have the mean delta, which takes in a default value of 0.0001.
And this means that if after say, ten epochs we have a change in the validation loss.
But this change is less than this mean delta, then we'll consider that that isn't a change and hence
we are going to still reduce the learning rate by this factor right here.
We also have the cool down and then the minimum learning rate below, which we wouldn't we wouldn't
want to drop our learning rate as described here.
This cool down is a number of epochs to wait before resuming normal operation.
After the learning rate has been reduced.
We are going to create this callback very easily and this time around we're going to monitor the validation
accuracy.
So if the validation accuracy doesn't increase after two epochs, we are going to reduce the learning
rate by a factor of 0.1, meaning that if we had a learning rate of, say, 0.01, and that this validation
accuracy hasn't increased after the two epochs, we are going to reduce this such that this becomes
0.01 times 0.1, which is this factor right here just as before.
We are going to add this plateau callback and then train our model.
After training for five epochs, we can observe that we have this learning rate which has been reduced
after the third epoch.
And this is because after this two epochs there is no improvement in this initial validation accuracy.
And so that's why the accuracy is going to drop from 0.01 to 0.001.
Now that's it for this section.
Thank you for getting up to this point and see you next time.