1
00:00:00,330 --> 00:00:06,570
Hello, everyone, and welcome to this new and exciting session in which we are going to treat and sampling.

2
00:00:07,200 --> 00:00:10,800
So up to this point we've been treating models separately.

3
00:00:10,800 --> 00:00:17,190
That is, we build a resonant model, train this model on some inputs and outputs and then later on

4
00:00:17,190 --> 00:00:23,730
expect to pass an input and get an output which corresponds to the input we passed in.

5
00:00:24,300 --> 00:00:33,480
Now, on the section on assembling, what will be building here will be an ensemble or a group of different

6
00:00:33,480 --> 00:00:42,240
models which will be put together to form one model or one block, such that now we pass our input and

7
00:00:42,240 --> 00:00:51,120
then we get our output wherein this output here is a weighted sum of all the individual outputs delivered

8
00:00:51,120 --> 00:00:52,760
by each and every model.

9
00:00:52,800 --> 00:01:01,830
So in this section we are going to look at this rest net 34 and this Pre-trained model is actually an

10
00:01:01,830 --> 00:01:03,260
efficient model.

11
00:01:03,270 --> 00:01:11,490
We could see this right here and we'll build and assemble a group or family of models from this to models

12
00:01:11,490 --> 00:01:13,380
which we have already built.

13
00:01:13,710 --> 00:01:21,360
Just before we start, it's important to note that we've already trained this Resnick 34 model and this

14
00:01:21,360 --> 00:01:24,570
Pre-trained model based on the efficient net model.

15
00:01:24,570 --> 00:01:31,080
So we have these two models and we want to create this ensemble of the matter of these two models here.

16
00:01:31,110 --> 00:01:40,950
Now, we should note that after evaluating these two models, we got 84.1% accuracy and 82.9% accuracy

17
00:01:40,950 --> 00:01:44,610
for the rest net and pre-trained models respectively.

18
00:01:45,180 --> 00:01:52,290
So now to create this ensemble, we're just going to simply start here and define our input.

19
00:01:52,740 --> 00:02:00,570
We have inputs, which is TensorFlow input, and then we specify the shape.

20
00:02:00,570 --> 00:02:07,100
So we have our shape, your configuration and size.

21
00:02:07,110 --> 00:02:12,420
There we go, we have the size, and then we put this orders here.

22
00:02:12,420 --> 00:02:16,250
So we have this shape which is specified.

23
00:02:16,260 --> 00:02:20,070
And then once we have the shape specified, we will have to outputs.

24
00:02:20,070 --> 00:02:28,650
Let's call this 1y1, which is from the rest net 34, it takes in the inputs and then we also have this

25
00:02:28,650 --> 00:02:33,060
other 1y2 from the Pre-trained model.

26
00:02:33,060 --> 00:02:35,900
So pre-trained model, text and inputs.

27
00:02:35,940 --> 00:02:38,340
Here we should have inputs and that's it.

28
00:02:38,370 --> 00:02:45,420
Now once we have this to outputs, what we are going to do here is we're going to create this ensemble.

29
00:02:45,420 --> 00:02:49,020
So we'll call this ensemble model.

30
00:02:49,020 --> 00:02:57,840
And it's a model, a TensorFlow model which takes in some inputs, which is actually these inputs here

31
00:02:57,840 --> 00:03:01,110
inputs, and then also the outputs.

32
00:03:01,380 --> 00:03:04,140
Now for the outputs, we're going to define it here.

33
00:03:04,140 --> 00:03:06,350
Let's let's call this output.

34
00:03:06,360 --> 00:03:08,880
So we have our output.

35
00:03:09,270 --> 00:03:18,030
And this output is a linear combination of these two models output here.

36
00:03:18,180 --> 00:03:27,180
So here we have 0.5 times Y one plus 0.5 times Y two.

37
00:03:27,480 --> 00:03:28,350
So that's it.

38
00:03:28,350 --> 00:03:34,320
So we have this output now and then here outputs equal output.

39
00:03:34,440 --> 00:03:35,700
So that's fine.

40
00:03:35,700 --> 00:03:41,220
So we have this ensemble model, we run this and that should be fine.

41
00:03:41,260 --> 00:03:42,120
This is okay.

42
00:03:42,120 --> 00:03:44,730
Now let's go ahead and evaluate this model.

43
00:03:44,730 --> 00:03:51,750
But before evaluating this model, you should compile it so we could get your and simply do this, so

44
00:03:51,750 --> 00:03:57,360
we could do ensemble model compile and that should be fine.

45
00:03:57,360 --> 00:04:03,750
So we have the ensemble model compiled now we'll take this off because we just wanted to do this for

46
00:04:03,750 --> 00:04:06,750
testing or to create that sample actually.

47
00:04:06,750 --> 00:04:14,430
So we have this ensemble model which we've created, and then now that we have this ensemble model created,

48
00:04:14,430 --> 00:04:17,100
let's go ahead and evaluate this model.

49
00:04:17,100 --> 00:04:18,060
So let's create a code.

50
00:04:18,060 --> 00:04:27,510
So your copy this passes out here and we have the ensemble assemble model.

51
00:04:27,540 --> 00:04:28,860
Okay, So we have that.

52
00:04:28,860 --> 00:04:31,470
Now let's evaluate the model and see what we get.

53
00:04:32,220 --> 00:04:33,060
There we go.

54
00:04:33,060 --> 00:04:38,790
We see we have a slight improvement from this higher accuracy.

55
00:04:38,790 --> 00:04:42,030
Here we go from 84.1 to 84.43.

56
00:04:42,030 --> 00:04:48,720
So this means that this ensemble model, which the combination of these two models is now better performing

57
00:04:48,720 --> 00:04:51,180
than each and every one of them.

58
00:04:51,180 --> 00:04:57,540
It should be know that this one was trained for 2040 epochs and this was trained for only 20 epochs.

59
00:04:57,540 --> 00:04:59,730
So if you train this longer, you should.

60
00:04:59,850 --> 00:05:07,140
Get results even better than this and and better still than sample model should perform even better

61
00:05:07,140 --> 00:05:08,270
than the two.

62
00:05:08,280 --> 00:05:13,560
And so with this, we've just seen the how to carry out and sampling with TensorFlow.

63
00:05:13,560 --> 00:05:21,030
And it should be noted that this technique is greatly used, especially in competitions like Kaggle

64
00:05:21,030 --> 00:05:27,780
and Indy, where you are struggling to get the best possible performance.

65
00:05:27,780 --> 00:05:34,530
And so after building or after training several models, you could then combine these models into one

66
00:05:34,530 --> 00:05:41,340
model and see if that gets you a step further in terms of model performance.
