We've got a model up here ready to go.
And we've checked out what summarizing it means.
But what we'll do first is create some callbacks so let's make a little heading here and you might be
wondering well what are callbacks and that's what we're going to dive into in this lesson and right
down here at callbacks are helper functions a model can use during training to do such things as save
its progress
check its progress or stop training early.
If a model stops improving and pluses a few more.
These are just a few things and these are the ones that we are going to implement.
Now you might be wondering why should we implement callback if you want to find out a bit more about
model callbacks.
We can go tend to flow Kara's model callbacks and this is going to bring up the documentation Kerry's
custom callbacks
excellent so there's a few more callbacks that we can do in there.
Oh there's one tensor board we're gonna be setting that up.
And so while the model's training because it can be training for a long time you might want to figure
out what it's actually doing.
So there are times where you will once you scale up your models our model won't take this long but you
could be training a model for up to a week at a time especially some of the biggest deep learning models.
And so if your model is training for a week you're probably going to want to know how's it going what's
it doing.
And if it's training for too long.
Yes that's the thing you probably want to stop it early before it begins to over fit.
But we're getting ahead of ourselves here.
Let's create a couple of callbacks so we can see it in action.
That's going to help solidify what's going on.
Same with what's going on up here.
This functions a fair bit to take in.
But once we start to use it once we start to try and a model you'll start to see what's happening now
what two callbacks do we want to make will create two callbacks one for tensor board which helps track
our model's progress and another for early stopping which prevents our model from training for too long.
Now these are a couple of handy callbacks that you can create with basically any model.
It's just tensor board which is like a dashboard for seeing how well your models are doing seeing its
progress.
Seeing that the loss function is getting reduced and that the accuracy is going up there.
The two ones main ones will be looking for an early stopping callback is something that if our model
is training for too long and it's stopped improving before it over fits we want it to stop training.
So let's go.
Here we go.
TENSOR low callback oh no we want tensor board tensor board so let's see.
I might actually go in here callbacks tensor board and see what it says there we go.
There's the documentation for the tensor board callback but let's code it up first so to low tensor
board into the notebook you can go load there's a magic function tensor board notebook extension we
go load extend tensor board
wonderful so that's going to load the tense avoid extension into our notebooks so we can have a look
at tensor board inside here inside the code lab notebook and now we're gonna see this in a moment.
So just bear with me to set up a tensor board callback we need to do three things maybe four that was
number one let's write that here to set up a tensor board callback we need to do three things actually
three things that was the first one.
Number one if I could type this would be amazing load the tensor board notebook extension we're gonna
put a little green checkmark there and then number two is create a tensor board callback which is able
to save logs to a directory.
So basically these logs are how our model is doing during training and pass it to our models
fit the function.
Now we haven't seen the fit function just yet but it's very similar to the one you've seen before in
socket learn and we go here visualize our models training logs with tensor board magic function we'll
do this after model training.
Wonderful.
So let's now create a function 12 step two here.
So the first thing we have to do is import date time because now tensor board callback we want to be
out of track each experiment.
And one of the best ways to track and experiment is by the time that you ran that experiment.
So that's why we need date time to access the current date and time you'll see this in a minute.
So we go here create a function to build a tensor board callback make it nice and simple Create tensor
board callback
and then here what we're going to do is create a log directory for storing tensor board logs.
So what we might set up is just a logs file in our dog vision project.
I want dog vision yes.
And new folder I'm going to call these logs so this is where we're going to store all of the logs for
our tensor board callback so we'll X out of that and now we're going to log Dir.
Create a variable OS path join.
So this is short for it's just accessing path names.
We need to have access to the path of this logs file.
So that's what we're doing here.
And we'll create drive slash my drive slash dog vision slash logs and then we're going to join it with.
So make it so the logs get tracked whenever we run an experiment.
So every time we fit our model we want to create some training logs for the current date and time.
So this is where we access date time
date time dot now dot string this line here is just saying hey get the exact current time so in my case
it would be Tuesday 525 p.m. And we're gonna go straight from time.
We can do almost any format you want here but we'll go for a pretty standard one of year month day hour
minute second so the log directory every time we run this function it's going to create
in logs with the name appended to it of the current date time.
Does that make sense or we'll see it when we run it anyway.
And then we want to return TAF carers callbacks tensor board and we want to pass it logged.
So see here and able visualizations for tensor board tensor board is visualization tool provided with
tensor flow beautiful.
So these callback logs events four tenths of all including metric summary plots training graph visualizations
beautiful.
That's what we want and we need to pass it along to the path of the directory where to save the log
files to be passed by tensor phone.
That's exactly what we've created so little green tech here.
Come on now area my emerges.
Wonderful and we'll run that.
So we've got our first callback create tensor board callback now and then next video we're going to
create an early stopping callback and then we might be able to start getting our model ready to train.
Now actually we're probably ready to train now because we're setting up these experiments that we want
to be at a run back to back to back.
This is why we're creating callbacks ready to go.
So I'll see in the next video we'll create an early stopping callback.