‫We've got a model up here ready to go, and we've checked out what summarising 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 write down here.
‫Callbacks are helper functions a model can use during training to do such things.
‫As save it's progress.
‫Check its progress or stop training early.
‫If a model stops improving.
‫And plus, there's a few more.
‫These are just a few things and these are the ones that we're going to implement.
‫Now, you might be wondering why should we implement Kobach?
‫If you want to find out a bit more about model callbacks, we can go TensorFlow carer's model callbacks.
‫And this is going to bring up the documentation.
‫Cara's custom callbacks.
‫Excellent.
‫So there's a few more callbacks that we can do in there.
‫Oh, there's one tense board.
‫We're going to be setting that up.
‫And so while the model is 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'll 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 train a model,
‫you'll start to see what's happening now.
‫What two callbacks do we want to make?
‫We'll create two callbacks one for the 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 model is 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'll go tensorflow callback.
‫Oh, no.
‫We want a board.
‫Of board.
‫So let's say we might actually go in here.
‫Callbacks, tense aboard and see what it says.
‫There we go.
‫There's a documentation for the tensor board callback, but let's code it up first.
‫So to load tensor board into the notebook, you can go load.
‫There's a magic function, tensor board, notebook extension.
‫We go load extent tensor board.
‫Wonderful.
‫So that's going to load the tensor board extension into our notebook so we can have a look at tents
‫aboard inside here, inside the co lab notebook.
‫And now we're going to see this in a moment.
‫So just bear with me to set up a tent aboard Colback.
‫We need to do three things, maybe four.
‫That was number one.
‫So let's write that here to set up a tense a board cool back.
‫We need to do three things.
‫Actually, it's three things.
‫That was the first one.
‫Number one, it's like a type.
‫This would be amazing.
‫Load the tents, the board, notebook extension.
‫We're going to 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 function.
‫Now, we haven't seen the fit function just yet, but it's very similar to the one you've seen before
‫in Cyclone.
‫And we go here visualize our models training logs with.
‫Tencent, a board magic function.
‫We'll do this after model training.
‫Wonderful.
‫So let's now create a function.
‫We'll do step two here.
‫So the first thing we have to do is input date time, because our tensor board callback, we want to
‫be able to track each experiment.
‫And one of the best ways to track an 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'll go here, create a function to build a tense board callback.
‫Make it nice and simple.
‫Create tense a board callback.
‫And then here, what we're going to do is create a log directory for storing tense 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 tents aboard Colback.
‫So we'll x out of that and now we'll go log dur create a variable O's 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 5:25 p.m..
‫And we're going to go string from time.
‫We can do almost any format you want here, but we'll go for a pretty standard one of year, month,
‫day, our 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?
‫Well, we'll see it when we run it anyway.
‫And then we wanted to return to Scarers doc callbacks.
‫Tense aboard.
‫And we want to pass it logged.
‫So see here.
‫Enable visualizations for tensor board.
‫Tensor Board is visualization tool provided with TensorFlow.
‫Beautiful.
‫So it's called back logs, events for tech support, including metrics, summary plots, training,
‫graph visualizations.
‫Beautiful.
‫That's what we want.
‫And we need to pass it a log to the path of the directory where to save the log files to be passed by
‫TensorFlow.
‫That's exactly what we've created.
‫So.
‫Little green tick here.
‫Come on.
‫There you go.
‫My emojis.
‫Wonderful.
‫And we'll run that.
‫So we've got our first callback.
‫Create tense of callback.
‫Now, in the 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 able to 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.