1
00:00:11,030 --> 00:00:17,660
In this video, we will be looking at how to use concerns for human activity recognition, please note

2
00:00:17,660 --> 00:00:21,380
that at this point you have seen all the code and you know where to get the data set.

3
00:00:21,860 --> 00:00:25,070
So if you'd like to complete this exercise yourself, please do so.

4
00:00:25,070 --> 00:00:29,100
Now, we'll be looking at two versions of this model.

5
00:00:29,570 --> 00:00:34,730
One, CNN that looks purely at the Time series and the combined model that incorporates the tabular

6
00:00:34,730 --> 00:00:35,410
features.

7
00:00:35,870 --> 00:00:39,020
So it should be pretty straightforward given what we already know.

8
00:00:39,710 --> 00:00:41,360
So let's check out these imports.

9
00:00:41,930 --> 00:00:46,700
You'll notice that I've imported some optional layers, such as flatten and global average pulling.

10
00:00:47,150 --> 00:00:50,450
You might want to try these as alternatives to global max pulling.

11
00:00:55,880 --> 00:00:58,670
The next step is to download our data, which you've seen.

12
00:01:07,410 --> 00:01:12,990
The next step is to define our data loading function, which you've seen, as you recall, this already

13
00:01:12,990 --> 00:01:15,720
returns inputs of size and by TBD.

14
00:01:16,200 --> 00:01:18,510
So there is no more work that needs to be done.

15
00:01:25,970 --> 00:01:32,090
The next step is to define our CNN, so for this model, I decided to use a kernel size of five for

16
00:01:32,090 --> 00:01:35,030
the first convolution with the pooling size of three.

17
00:01:35,870 --> 00:01:42,130
This is appropriate since our Time series now is much larger than the previous examples, as you recall.

18
00:01:42,320 --> 00:01:45,940
Tea is equal to one twenty eight, whereas before it was just 10.

19
00:01:46,850 --> 00:01:51,620
So for larger images and larger time series, larger kernels make sense.

20
00:01:52,220 --> 00:01:55,850
As always, the only way to know the results is to do the experiments.

21
00:01:56,160 --> 00:01:59,990
Otherwise, note that at this point this CNN is pretty unremarkable.

22
00:02:05,330 --> 00:02:07,460
The next step is to come out of that summary.

23
00:02:12,790 --> 00:02:17,530
So if you'd like, please check to see how the output shape changes after every layer.

24
00:02:18,280 --> 00:02:20,960
Note that sometimes the values don't divide evenly.

25
00:02:21,490 --> 00:02:26,650
Now, the minute details aren't really a concern for most people, but sometimes students ask, well,

26
00:02:26,650 --> 00:02:28,060
what happens in this case?

27
00:02:28,570 --> 00:02:33,550
If you want a definitive answer to this question, I'd encourage you to look at the source code to see

28
00:02:33,550 --> 00:02:34,930
how those cases are handled.

29
00:02:35,410 --> 00:02:39,850
For example, it might ignore the first of the final pixel or something of that nature.

30
00:02:44,070 --> 00:02:49,310
OK, so the next few steps are all things we've seen before, we create our checkpoint, we call comp.

31
00:02:49,310 --> 00:02:51,870
Then we call fit and we wait for it to finish.

32
00:02:59,640 --> 00:03:01,880
The next step is to plot the loss epoch.

33
00:03:06,160 --> 00:03:07,890
So the last prepack looks fine.

34
00:03:11,890 --> 00:03:14,530
The next step is to check the accuracy prepack.

35
00:03:19,140 --> 00:03:21,440
So the accuracy prepack looks fine.

36
00:03:24,360 --> 00:03:27,150
The next step is to check our best model predictions.

37
00:03:31,570 --> 00:03:35,710
As usual, you should compare this result to the other models we've seen.

38
00:03:38,760 --> 00:03:44,190
The next step is to create our combine's model, so we'll start by defining a function to load in the

39
00:03:44,190 --> 00:03:46,340
features which you've seen before.

40
00:03:52,180 --> 00:03:54,640
The next step is to build our combined model.

41
00:03:55,300 --> 00:03:56,800
So this has three parts.

42
00:03:57,280 --> 00:04:01,450
The first part is the convolution and pooling part, which is the same as before.

43
00:04:01,840 --> 00:04:04,030
So that's where the time series passes through.

44
00:04:07,280 --> 00:04:11,720
The second part is the anend part, which is where the tabular features is passed through.

45
00:04:13,250 --> 00:04:19,050
So at this point, both X and next, to represent different feature vectors from different sources.

46
00:04:19,550 --> 00:04:24,860
The third part is to combine these two feature vectors together and apply one final dense layer.

47
00:04:25,340 --> 00:04:30,090
As you recall, it's possible to add more dense layers anywhere you see a dense layer.

48
00:04:30,560 --> 00:04:32,960
So please try that if you think it might help.

49
00:04:37,420 --> 00:04:42,130
The next step is to call Plott model, I've mentioned that this time since it's no longer trivial.

50
00:04:48,570 --> 00:04:53,680
So at the bottom, we can see that there are essentially two parallel paths in the neural network.

51
00:04:54,060 --> 00:04:58,710
One for the Time series, which goes through the CNN and one for the tabular features.

52
00:05:01,120 --> 00:05:05,950
At the end, they get combined and then they pass through one final mini neural network.

53
00:05:08,950 --> 00:05:14,080
The next step is to create our checkpoint code, compile and call the fit function as per usual.

54
00:05:23,220 --> 00:05:25,440
The next step is to plot the Los Prepack.

55
00:05:29,470 --> 00:05:31,200
So the last report looks fine.

56
00:05:33,850 --> 00:05:36,370
The next step is to plot the accuracy prepack.

57
00:05:40,230 --> 00:05:42,350
So the accuracy prepack looks fine.

58
00:05:45,340 --> 00:05:49,120
The next step is to load up our best model and check how well it performs.

59
00:05:55,800 --> 00:05:58,780
So as you can see, our model now does even better.

60
00:05:59,700 --> 00:06:04,830
As always, please compare this results with the other models we've seen and check which one performs

61
00:06:04,830 --> 00:06:05,430
best.

62
00:06:06,450 --> 00:06:12,290
You might want to run this script several times to see whether the result varies from my experiments.

63
00:06:12,300 --> 00:06:16,910
I've seen that the combined CNN can achieve the best results that we've seen so far.
