In this video, we will be looking at how to use concerns for human activity recognition, please note
that at this point you have seen all the code and you know where to get the data set.
So if you'd like to complete this exercise yourself, please do so.
Now, we'll be looking at two versions of this model.
One, CNN that looks purely at the Time series and the combined model that incorporates the tabular
features.
So it should be pretty straightforward given what we already know.
So let's check out these imports.
You'll notice that I've imported some optional layers, such as flatten and global average pulling.
You might want to try these as alternatives to global max pulling.
The next step is to download our data, which you've seen.
The next step is to define our data loading function, which you've seen, as you recall, this already
returns inputs of size and by TBD.
So there is no more work that needs to be done.
The next step is to define our CNN, so for this model, I decided to use a kernel size of five for
the first convolution with the pooling size of three.
This is appropriate since our Time series now is much larger than the previous examples, as you recall.
Tea is equal to one twenty eight, whereas before it was just 10.
So for larger images and larger time series, larger kernels make sense.
As always, the only way to know the results is to do the experiments.
Otherwise, note that at this point this CNN is pretty unremarkable.
The next step is to come out of that summary.
So if you'd like, please check to see how the output shape changes after every layer.
Note that sometimes the values don't divide evenly.
Now, the minute details aren't really a concern for most people, but sometimes students ask, well,
what happens in this case?
If you want a definitive answer to this question, I'd encourage you to look at the source code to see
how those cases are handled.
For example, it might ignore the first of the final pixel or something of that nature.
OK, so the next few steps are all things we've seen before, we create our checkpoint, we call comp.
Then we call fit and we wait for it to finish.
The next step is to plot the loss epoch.
So the last prepack looks fine.
The next step is to check the accuracy prepack.
So the accuracy prepack looks fine.
The next step is to check our best model predictions.
As usual, you should compare this result to the other models we've seen.
The next step is to create our combine's model, so we'll start by defining a function to load in the
features which you've seen before.
The next step is to build our combined model.
So this has three parts.
The first part is the convolution and pooling part, which is the same as before.
So that's where the time series passes through.
The second part is the anend part, which is where the tabular features is passed through.
So at this point, both X and next, to represent different feature vectors from different sources.
The third part is to combine these two feature vectors together and apply one final dense layer.
As you recall, it's possible to add more dense layers anywhere you see a dense layer.
So please try that if you think it might help.
The next step is to call Plott model, I've mentioned that this time since it's no longer trivial.
So at the bottom, we can see that there are essentially two parallel paths in the neural network.
One for the Time series, which goes through the CNN and one for the tabular features.
At the end, they get combined and then they pass through one final mini neural network.
The next step is to create our checkpoint code, compile and call the fit function as per usual.
The next step is to plot the Los Prepack.
So the last report looks fine.
The next step is to plot the accuracy prepack.
So the accuracy prepack looks fine.
The next step is to load up our best model and check how well it performs.
So as you can see, our model now does even better.
As always, please compare this results with the other models we've seen and check which one performs
best.
You might want to run this script several times to see whether the result varies from my experiments.
I've seen that the combined CNN can achieve the best results that we've seen so far.