1
00:00:00,450 --> 00:00:05,820
Hi and welcome back to the course in this section, we'll take a look at something called callbacks,

2
00:00:05,820 --> 00:00:11,040
which allows us to implement early stopping, check pointing, learning, read schedules and much more.

3
00:00:11,520 --> 00:00:14,250
They're available in broad Keras and PyTorch.

4
00:00:14,250 --> 00:00:17,100
However, it's much easier to implement and carries it away.

5
00:00:17,520 --> 00:00:23,520
But let's begin so callbacks callbacks are used to perform different actions at different stages in

6
00:00:23,520 --> 00:00:24,000
the training.

7
00:00:24,270 --> 00:00:25,650
But why is this useful?

8
00:00:26,160 --> 00:00:29,910
Well, what if we wanted to see one model after the end of each epoch?

9
00:00:30,360 --> 00:00:33,300
Or what if you create a model for 100 epochs?

10
00:00:33,300 --> 00:00:35,850
But after Tuti so that all of a fit?

11
00:00:36,300 --> 00:00:40,890
Wouldn't you want a way to monitor training so that you can stop trading and stop wasting time at that

12
00:00:40,890 --> 00:00:41,250
point?

13
00:00:41,850 --> 00:00:47,070
Or what if we wanted to log information somewhere during training that can be analyzed elsewhere?

14
00:00:47,520 --> 00:00:49,760
Well, callbacks allow all of those things.

15
00:00:49,770 --> 00:00:50,700
They are the solution.

16
00:00:51,240 --> 00:00:55,200
They can be used to perform a number of things, such as early stopping, which we discussed in our

17
00:00:55,200 --> 00:01:02,250
regularization section model, check pointing, learning, read, scheduler logging and remote monitoring,

18
00:01:02,610 --> 00:01:04,020
as well as a custom function.

19
00:01:04,050 --> 00:01:06,810
So let's take a look at this graph here.

20
00:01:07,350 --> 00:01:11,820
You can see this is an example of overfitting model, and you would want the model to stop here.

21
00:01:12,210 --> 00:01:13,800
This is what early stopping does.

22
00:01:13,800 --> 00:01:15,960
It allows us during the training process.

23
00:01:16,440 --> 00:01:22,660
It allows us to if for validation, los stagnates or stops decreasing and actually can start to increase.

24
00:01:22,680 --> 00:01:29,400
It allows us to do set something called early stopping criteria that allows our model to stop trading

25
00:01:29,400 --> 00:01:32,460
at that point and ends the training process so you don't waste time.

26
00:01:33,060 --> 00:01:35,070
What about model check pointing?

27
00:01:35,550 --> 00:01:38,670
Well, this is how you set the parameters and carrots for model check point.

28
00:01:38,790 --> 00:01:40,140
But what exactly is this?

29
00:01:40,170 --> 00:01:46,320
Well, models are pointing allows us during training to periodically save the weights after each epoch.

30
00:01:46,800 --> 00:01:52,770
That's very good because as you saw in earlier stopping, sometimes the best model isn't the one that

31
00:01:52,770 --> 00:01:54,090
you trained after the most ebooks.

32
00:01:54,090 --> 00:01:59,310
In fact, it could be one of the early models that just got it got to be its right that give us a very

33
00:01:59,310 --> 00:01:59,880
good loss.

34
00:02:00,330 --> 00:02:06,850
So you want to actually store we to monitor the validation loss, and you can see if the best model

35
00:02:06,850 --> 00:02:11,070
of, well, trading so you can train for a thousand epochs if you had all the time in the world and

36
00:02:11,160 --> 00:02:17,720
powerful GPUs, and it would save the best model out of all of those ebooks using the models are pointing,

37
00:02:17,730 --> 00:02:18,660
which is quite cool.

38
00:02:19,110 --> 00:02:25,860
So it's also allows us to resume trading in the event of a crash, and the checkpoint actually contains

39
00:02:25,860 --> 00:02:27,680
the model of weights and the model itself.

40
00:02:27,690 --> 00:02:32,790
So when you see if all those checkpoints that are light allow you to resume training or whatever you

41
00:02:32,790 --> 00:02:37,980
want to do, all those all the checkpoints are basically the model weights at a time, and this is how

42
00:02:37,980 --> 00:02:38,940
it can be configured.

43
00:02:39,750 --> 00:02:42,510
So now let's take a look at lifting weights scheduler.

44
00:02:42,960 --> 00:02:45,820
So this is what it looks like for a living which has Shatila.

45
00:02:45,840 --> 00:02:47,280
But what exactly is it?

46
00:02:47,670 --> 00:02:53,250
Well, we can avoid having a little loss oscillate around a global minimum, which is not what you want.

47
00:02:53,250 --> 00:02:54,780
You wants to find a global minimum.

48
00:02:55,980 --> 00:03:00,600
And we do that by attempting to reduce the learning rate by a specified amount.

49
00:03:01,050 --> 00:03:05,460
So if no improvement is seen, you know, a monitored metric, which is a validation list, typically

50
00:03:06,030 --> 00:03:07,730
we wait a certain number of epochs.

51
00:03:07,740 --> 00:03:12,510
That's the patient setting, which you see here and then does call back and then it reduces learning

52
00:03:12,510 --> 00:03:14,700
rate by a factor that is set here.

53
00:03:14,700 --> 00:03:15,330
Point two.

54
00:03:15,600 --> 00:03:22,920
This is a minimum delta can change, so you can see by using this this function called reduced learning

55
00:03:22,920 --> 00:03:28,950
rate on pilot to just quite descriptive of what it does if you're living, if your loss stops decreasing.

56
00:03:29,460 --> 00:03:33,630
This automatically reduces the learning rate, so it's quite dynamic and quite useful.

57
00:03:34,200 --> 00:03:36,570
You can also do something like logging like this.

58
00:03:36,990 --> 00:03:42,930
You can automatically log your models training stats, using checkpoints, tens of what checkpoints

59
00:03:42,930 --> 00:03:43,200
here.

60
00:03:44,000 --> 00:03:50,000
The stores stausholm model results in the directory and dot logs directory, and you can just load a

61
00:03:50,000 --> 00:03:50,560
tentacle.

62
00:03:50,670 --> 00:03:54,900
Is doing these commands in your Pi Python book and it brings up this.

63
00:03:54,900 --> 00:04:00,750
This brings up this nice web UI where you can actually track and monitor your model as a tree and so

64
00:04:00,750 --> 00:04:02,070
you don't get the graphs afterwards.

65
00:04:02,070 --> 00:04:05,000
You can look at the graphs life, which is quite cool.

66
00:04:05,010 --> 00:04:09,190
I will be doing that in all two models that we will be treating in club.

67
00:04:09,210 --> 00:04:10,620
So stay tuned for that.

68
00:04:11,220 --> 00:04:15,120
So that's it for this section next to what we'll do.

69
00:04:15,420 --> 00:04:18,960
Well, actually look at callbacks in the court and Keras and PyTorch.

70
00:04:19,410 --> 00:04:20,550
So stay tuned for that.

71
00:04:20,790 --> 00:04:21,240
Thank you.
