In this video, we will be doing code preparation for CNN's in order to preview the code that we will
write next.
As before, the main purpose of this lecture is to show you the syntax so that you are not surprised
when we use it later.
Now, whether or not you understand what this code is doing will be dependent on whether you watch the
previous lectures.
If you did, then you will know what's going on under the hood.
If not, that's OK too.
You can simply treat this like an API.
OK, so the first thing to discuss is that the structure of this code is no different than what we had
for eons.
You'll find that the setup for this video, meaning the previous conceptual lectures, is way more meaty
than the actual implementation.
Thanks to our hard work in the previous section, we already know most of what to do.
The new parts are really just learning about the syntax for the new layers.
So without further ado, let's review what we've already learned.
We know that the first step is to build our model.
The syntax for that is precisely what we will learn very shortly.
The next step is to call the compile function.
The arguments to this, such as the loss, will be dependent on what task you are doing, but it works
the same way as before.
The next step is to call the FID function.
This time the input data extranet next test are now NBT by the arrays.
After training the model, we would like to use it to make predictions.
Thus we use the predictive function parsing in the input data.
We would like to make predictions for OK, so this is exactly the same as before, except that now the
data has the shape and by TBD.
The next step is to understand the syntax for building a CNN.
So this should be pretty straightforward.
We'll start with what a convolutional layer looks like mathematically.
You can think of this is doing W, star X plus B and then passing it through some activation function.
As you recall, the star means convolution.
In this case, W is the filter and B is the bias term.
As per usual, the activation function is typically evalu.
OK, so let's check out the arguments for kind of one D.
The first argument is the number of output feature maps as mentioned previously.
This usually grows larger at every subsequent layer of the CNN.
The next argument is the filter size, typically we choose small values relative to the input size.
So normally you see values like three, five and seven.
The next argument is the activation, as mentioned in modern times, we typically just use the rescue
at this point.
These are the only arguments we need to know.
Also note that for two dimensional convolution, the arguments would be exactly the same, except now
the layer is called a kind of 2D instead of kind of one de.
One option, which is normally not used, is that you can specify a different height and width for the
kernel, but if you only pass in a single number, it assumes that they are the same.
OK, so here's an example of a full CNN using the kind of one delayer that we just learned about, you
should be able to match this code with the previous diagrams we've seen.
So we start with an input layer which specifies the input size.
As mentioned, this is TBD for added dimensional time series of length t.
The next step is to use a kind of one d as before.
All these values are hyper parameters which can be freely chosen for the most part.
The next step is to use pooling by default, if you just pass in into it assumes that the strait is
also two, such that the time dimension will shrink by half.
The next step is to do another kind of one d notice that the number of feature maps is increasing as
is typical, the next step is to do another max pool.
The next step is to do yet another kind of one day notice.
The number of feature maps has doubled once again.
Now, remember that the number of convolutional layer's is up to you, it's your job to experiment and
find out what works best for your particular data set.
At this point, we're going to stop doing convolutions and have one final global max pooling.
Alternatively, you could just use flatten.
The final step is to have our final dense layer with however many outputs we need for the current task.
OK, so that's everything you need to know in order to build a one d convolutional neural network.
I hope you've seen that once.
You know how to build Andsnes.
CNN's are pretty simple.
Now, for completion sake, I'd also like to show you at this point how to build a CNN four images.
As you recall, it's possible to convert a time series into an image.
I hope you'll agree that this is surprisingly simple.
Only two changes need to take place.
Firstly, the shape of the input now has three dimensions height with a number of features.
Now, for typical everyday images, this value is usually three, since we use three channel colour
systems and cameras and computers, for example, RGB or HSV four time series.
This will simply be, however, many variables your Time series has.
The second thing that has the changes anywhere you previously saw one, did you now see TUTTY?
So as mentioned, either way you want to treat your time series.
The CNN itself looks in nearly the same.