We are now ready to build our model.
And up to now, neural networks have been performing quite well.
We had seen previously that if we have three neurons, that's 1 to 3 in the input and in the output
we have to re neurons to, then there'll be nine different connections here and hence nine different
weights plus the bias.
But for this example, let's consider only the weights.
So we have nine different parameters for three inputs, three outputs.
And if here we have five construction only the weights we would have three times five.
That's 15 different parameters.
Now, if we're dealing with an image like this one, so let's consider this image, which is 224 by
224 by three, Image three for the three different red, green and blue channels.
So we have this input image now.
So unlike previous examples where we would have features or specifically in this case input features
which not contain as many elements as this, we now have this case where if we want to count the number
of features or the number of pixels, we would have 150,528 different input features to take into consideration.
Hence, instead of having a total number of three right here, we are going to have 150,528 different
values.
And if we want to do the same competition which got us, this number of parameters would have 150,000
times three.
That's approximately five 450,000 different parameters.
Now, what if we modify this number of neurons right here and take a thousand neurons in this output
right here?
We'll see that we'll move from 150,000, or rather from 450000 to 150 million different parameters.
Where each and every parameter has to be trained and optimized.
This becomes clear that deep neural networks like this are better still than layers of fully connected
layers aren't scalable.
Since when we increase the number of features, the total number of parameters also increase considerably.
Hence, we need to build a type of layer, unlike this one where each neuron isn't connected to all
the previous neurons, and this layer happens to be the convolutional layer.
In order to better visualize this, we'll use this demo platform from Rice and University.
So here we'll put in a figure, let's say four, and then we'll see exactly how this confidence work.
So we have this and then we have this input right here.
So we get this input, we have some weights and then this output features.
Note how to obtain this particular pixel right here.
Only a few of these inputs are used.
And so here we call this the receptive field.
As you could see, we have the receptive field right here.
And if we take this other example you see is on receptive field, you see to get this value only these
four values you see below, actually this one, this, this and this.
So you could see here, let's scroll back.
Okay.
So only those four values have a role to play when it comes to giving us the corresponding value we
have here.
And so unlike with a dense layer where to obtain this value, we needed to link this to each and every
previous neuron.
Now, only just some neurons in this neurons receptive field play a role in getting this value.
Another great tool for better understanding the convolutional layer is this CNN explainer.
Actually, CNN stands for Convolutional Neural Networks.
This is created by Jay Wong, Robert Omar, Pak Di's Fried Kang and Pablo.
We are really grateful for this tool.
Before getting back to the explainer, let's take this example right here.
We have a 4x4 image, so we have 16 different pixels.
If we flatten out those pixels that if we put those pixels out like this, such that we have those inputs
and then in the output we have four different neurons, then here we would have 16 by four connections
that will have 64 different parameters excluding the bias.
But with the conf layer, we could leave from this 4x4 to just a two by two so we could leave from this
4x4 to these two by two.
With just nine parameters.
So we'll have what we call a kernel here or filter.
So we have this filter which is three by three, which actually corresponds to our weights, which we've
seen already.
This kernel here, kernel size three will produce this output of two by two, which when we flatten
out, can give us this output right here.
And so instead of working with 64 parameters, we're working with nine parameters.
If we want to replicate that same example in the CNN explainer, here is where we get we have this input
right here which produces this output.
Now notice how we specify that the kernel size equal three, and because the kernel size equal to three,
we are able to get this output.
But how is this output gotten?
You'll see that at this top left corner we are going to feed our kernel, which is of size three by
three.
So we put in our kernel right here and then we take each and every value of our kernel and multiply
it with the corresponding value in the input to obtain the first value.
You see how we pass this kernel on the input.
So at this top left position with the kernel.
Notice how all we have a three by three kernel which is passed on this input and we have the output
right here.
Then to get the next position to get this next output.
You see how the kernel is passed on this next part of the input.
And the way we get this next part is by simply sliding to the true the image.
You see how we left from this.
We slide that through the image and we got this.
We got this next output.
And since we've got into the end, we move to the next position, which is this.
We get this next we get this next value right here.
And then from here we slide again to this end and we finally get this value.
So that's how we get all this outputs from the inputs and the kernel or the filter.
We can now go ahead and increase this input size.
Let's take, for example, seven.
You see we have input size of seven, seven by seven input image and then we have this output five by
five.
The reason why we have this five by five is because we have this kernel size of three.
If we get to increase the size of five, you see our output reduces.
You see when the kernel size gets to six, our output reduces.
Let's take this back to three.
So you take back to three, and this input of seven by seven gives an output of five by five.
We see how when we get to this, we have that output move.
Slide, slide, slide, slide, move to the next here, slide, slide, slide and so on and so forth
right up to the end.
So from here we see how the size of the receptive field of each of these outputs equal to three, which
is actually our kernel size.
The next thing to notice is reducing the kernel size permits us extract more features from the inputs.
You will see that since we have this input seven by seven with a kernel size of three, we have the
output five by five.
So we've extracted much more features from this input as compared to when we push a kernel size of six
here, we'll extract less features from this inputs.
Now though, using a smaller kernel size parameters, extract much more complex information or complex
features from the inputs working with larger kernels parameters extract larger input features.
One logical question which may come to your mind is how do I get the size of this output feature map
right here?
To get this, we'll use this formula where this output width is equals the input width minus the filter
size plus one.
If we take this example, we have an input weight of seven minus a field size of three plus one.
This gives us five.
So that's how we obtain this right here.
Now if we take, say, kernel size, let's take the kernel size to be four for example.
In that case we have seven minus the kernel size four, which is three plus one, which gives us an
output of four.
And that's how we obtain this output right here.
Now, in a case where you're designing a convolutional layer and you want to get a particular feature
map size.
So for example, in this case, if you.
Want to get an output size of three, then all you need to do is specify the scanner size to be equal
five and you should get this output.
Now, in some cases you may want to have a particular feature map shape, but using just the kernel
size, you wouldn't be able to get that.
And so to match up with the particular output shape would include a pattern.
Let's look at this pattern.
You see, we have an seven by seven.
And when we take this to one, you'll see that we go from seven by seven to now, nine by nine.
Notice how it's written here.
After pattern, we have nine by nine.
So we leave from this seven by seven.
Let's take this in this box right here, this internal box.
And then the pattern is us nine by nine.
Notice how after doing the pattern and if we play around with our kernel size, we go from one one to
the eight eight.
So we go from 11288, but with zero pattern and input size of seven.
You see we go to three, four and six.
So we cannot go up to eight, eight.
We're going to have an output of eight eight when the pattern is zero.
Whereas when we increase the pattern by one here, increase the pattern by one, that's one.
You see that we could go from we could get an output of say, let's put out a three, we could get an
output of seven of eight, you see up to one.
So that's it now.
Or we understand how this pattern works.
Basically, we just have our input and then we add this surrounding elements right here.
We just pad our input image.
Now the pattern generally we use is the zero pattern, though the other pattern methods, but the zero
pattern is one of the most common since it's easy to use and it's computationally less expensive to
work with.
So that said, there our pattern.
And then we also have another advantage of working with the pattern, which is that of ensuring that
the color pixels have an influence on our output features which are generated.
Now let's take this back to zero pattern.
We have zero pattern and we have this input image right here.
If we're doing an image in which most of the information or most of the relevant information is centered,
then there is actually no issue since this filter right here will go through each and every pixel we
have where we have this person in the image.
Now, if we modify this image such that we have a person's let's suppose we have a person's face here
just at the corner of the image, you'll see that unlike with this image where this person was centered
and that our channel was able, our filter was able to pass through each and every part of this image.
With this one, we have a different scenario.
We've just modified this so it looks similar to what we had here.
Now what we could do is if we monitor the number of times this filter goes to the person's head would
see that we would have your one time because our filter passes here once the next time after the sliding,
we'll have this.
So second time, the next time after this other sliding will lead to this four times.
So unless it passes through the head and then yeah, we have five times.
No, we have one, two, three, four times actually.
But in this case, since we are on the borders, you see we have this one time and that's practically
all.
So we see that in this example or in this case where we are on the borders.
This influences the outputs in a smaller way or exerts less influence on the values we get in this feature
maps which are generated.
So in an example where this let's suppose an example where all this wasn't there and that where our
information lies most is this you'll find that it would have been better.
To at least pass through this head region, just as we did with this year, where we pass through the
head region four times.
And we're able to extract very useful information from this image because our filter goes through this
many more times.
Now, to remedy the situation, we have the pattern.
You see that when we increase the pattern.
So let's take this to one.
We've increased the pattern.
Let's increase the pattern to all years fixed to just one anyway.
We just increase the pattern to one and then we'll retake that example.
Now we're taking the example.
We'll see that if we maintain our filter size of two, this filter here will at least touch the hair,
although slightly.
And then the second one does this twice.
So in this case, our filter touches the head twice as compared to previously, where it touches the
head only once and hence this useful information has more influence on the output features which are
being generated right here and which is very important as practically that's what we're trying to do.
We're trying to extract information from this input and pass to the output.
Another hyper parameter which we could look at is a stride.
Now note that for now we've looked at this one, this and this.
So here's what we call the hyper parameters.
We have this stride and we'll understand actually how this works.
For now, we'll dealing with a stride of 1y1 simply because you just slide in through one step before
going to the next.
So you just slide one, one, one, and so on and so forth.
Now, if you move this to two, we start from this position right here, fix that, you start from this
position, there is a problem.
We get back to one and back to two.
You notice that as we go to one, this turns blue and then to two it turns red.
And the reason why it turns red is because there is no valid output or there is no whole number, which
with a slight stride of two, can produce an output.
So in fact, what we're going to do is we modify this input right here.
So modify this input is works now.
So it's possible for us to leave from this input of six to this output, but with a set of two.
So let's now understand how stripes work.
We start with this notice now how we're going to skip two steps instead of just one step.
So as we go, you see we skip two steps notice two, two, and that's it.
So we move to the next and now even moving downward, you see, it's not like with a straight one where
we just had one step, like we just tried one.
We just did this one step, but with a stride two, we're going two steps below.
So that's it.
Now, that said, increasing the size of our stride actually reduces the size of our output and hence
reduces the amount of information we extract from the inputs.
And so in general, we get better results by working with smaller kernels and smaller stride values.
Since we're able to extract more information from our inputs.
Generally the kernel sizes use as three.
The kernel size of three is generally used in practice and a stride of one.
So we may decide to use pattern or not.
And the new formula, when we include the pattern and the stride is given as such.
So we have the output equal to input size minus the field size plus two times the pattern divided by
the stride plus one.
In this case, if we have an input size of six, so here we have six, we have six minus field size
three.
Plus two times.
The pattern was our pattern one.
So it's plus two.
Divide that by the stride.
Stride is one and plus one.
There we go.
We have an answer of three plus two, which is five and then plus one, which is six.
So that's how we obtain this output size, Right.
Also note that one good thing with working with a library like TensorFlow is when you don't know the
exact pattern to use such that you have particular output size, you could specify the pattern to be
valid.
Once you specify the pattern to be valid, TensorFlow automatically calculates the pattern for you such
that the output you want matches up.
Up to this point, we've been supposing that our input image is two dimensional.
That is, we have a height and a width.
Now what if we use the kinds of images we have in real life that is three D images where we have the
right channel, the Green channel, and the blue channel.
So if we have this RGV image right here, RGV image, we'll see how we get the output.
Now, the way this is done is quite straightforward.
So what we have is in this case we include this pattern.
So you see zero palette.
We've included this pattern and then we have our channel right here.
Now notice how we have this channel, and then it goes through this first part of this top left corner.
And what we do is we multiply each value right here.
We have negative one times zero plus negative one times zero, plus negative one times zero, and so
on and so forth.
Up to plus negative one times zero.
Right here you have negative one times four.
So basically what we're doing here is kind of like a dot product.
So we're taking all these elements multiplied by the corresponding elements and then adding all this
up.
Once all this added up, we should have 41.
So you could take this as a simple exercise and then you should be able to get 41.
And then we have this other channel right here where we repeat the same process.
We have this and then we have this kernel, we have this.
So here what we do is we have we take this, we obtain this value, take this in is value.
This often is value.
And then we add all this up to get this angle of 41.
Now note that we also have the bias which we've included.
So for now we have this 41.
Now we move to the next step, so we slide through next step.
Yeah, the stride is equal one actually.
From here we do the same process negative one times zero.
This negative one times is zero added up and an all of that.
So all that added up, all this added up, all this added up.
We have 12.
We repeat the same process right up to the end.
So that's how we obtain our output right here.
You could also check out on this other more visually appealing example in the and Explorer website.
So here we double click on this and then we see exactly what's going on.
We have the.
You see how we forming this output by sliding through the channels over the inputs.
So you're I click on this, you see a slide through this and you see how all these values are multiplied
and then add it together to form the output.
So that's it.
From this point we move to this explained visually.
Project by Cetus.
Filtering is a core part of image processing.
And since we're dealing with image data here, it's important for us to better understand how this works.
So right here we'll choose a kernel or filter, or let's pick this sharpen filter right here on this
shopping channel.
Notice how once we pick a kernel, this values change that the values of the filters actually changed.
Let's take this outline.
Notice a change.
Now let's keep this outline and then we notice that every time we hover over this input image, we have
the values right here that's to the right.
So for now, we have this.
And then let's notice that here we have this negative one that's negative one times at this position.
Notice at this position we have the value to 155, so to 55 times negative one plus 255 to -1 plus or
non value and none here because we have the borders.
So there is no value and then we have to 49 times -1 to 55 times 8 to 33 times -1 to 55 times negative
one.
And then all this sums up to give us a given value since we have this unknown values here is unknown,
so we have no value there.
But if we change this position and then we fit around the eye region, you see we have a value of -533.
So we notice that no matter the image we're put in, your will always get an output where the outlines
are being highlighted.
So if you take out this image which we just imported of Elon Musk, you see that the output is this
image right here which highlights the edges.
And so as is explained here, the highlight large differences in pixel values which generally occur
at the edges.
So around this region you see this large differences have been outlined as compared to this zone here
where there is no difference.
And since there is no difference, we just have this black region.
So here again you see that we have the filter.
That's it.
This is the exact same value we have right here.
We have the filter.
And then this example shows us how this output is gotten.
Now, the major difference between what we're doing right here and the convolutional neural networks
is that with this we know this channel values.
So we know that we have this matrix negative one, negative one, negative one, negative one eight,
negative one, negative one, negative one, negative one, which is an edge detector.
So we know this and then we know the obvious output.
But with a convolutional neural network or with a convolution layer to be specific, what we do is initially
we just initialize this values and we let the model do in training to learn these values automatically.
So these values are learned by the model during training automatically.
One of the very first convolutional neural networks are called Nets, was built by Yann LeCun in 1989.
And right here we have the structure of this concept known as the Loonette.
This Loonette takes in an image.
Here we have a 28 by 28 by one image.
Yeah, we just have one channel, black and white image.
And then we pass this to a convolutional layer, which we've just seen after passing through the convolutional
layer, we have the sigmoid.
But also note that here we have a five by five kernel, we have plus two pattern.
So if it's zero pattern will add zeros around our input and then add another zero or another group of
zeros around our features.
Then from here we have this output 28 by 28 by six.
So shortly we'll see exactly how this output is gotten.
So we've seen we have the sigmoid activation from here, we have the pooling layer.
Now this is a subsampling layer and we'll understand how it works.
So we have two by two average pulling Kanno and with a straight of two from this we have another convolutional
layer with five by five kernel.
Here is no pattern and we have this output activation pulling flattening with flattening.
All the features have been modified so we'll leave from this three d tensor to a1d tensor.
And then we have this dense, fully connected layer followed by a sigmoid, followed by another dense,
fully connected layer followed by a sigmoid.
And finally, we have this.
Layer with output ten neurons.
And the exact reason why we have this output of ten classes or ten neurons since we have ten classes
is because we were predicting whether an input is either a one.
So these inputs are images of handwritten digits.
So we want to predict whether the 100 digit is a one or two or three up to nine.
And so here we have this and then we also have a zero.
So that makes ten.
So 0 to 9 gives us ten possibilities.
And that's why we have ten different classes right here.
Now for the next.
It was built to correctly classify whether an input image belongs to one of a thousand classes in the
image net data set.
So here we have this Alex net with a different architecture as we could see right here.
And now we'll go ahead and understand how all this outputs are gotten.
And so we'll be rebuilding the net architecture, but this time around, controlling an input 64 by
64 by three.
So right here we have the B channels, we have our G and B, if we pass this input now through this
convolutional layer, we are going to have this output.
And how do we get this output?
To get this output, we have to take into consideration this parameters which have been given to us
for a convolutional layer.
That said, the filter size is equal five.
So we have your filter size of five.
There is no pattern.
Stride equal one.
And then the number of filters equals six who calculate the number of parameters.
And the way these are the four most important parameters.
So here we have this, and this is what we call our filter.
We have this filter.
You see that we have the DOT products which are computed to get the outputs as usual.
And so we take this like this how like are we have this, then we follow through with this and then
we follow with this.
So we take this and then computed the products and with the other two.
And then from this we add all this up to obtain each and every value for this very first feature map
right here.
So to obtain this feature map, we are using this filter.
Now, this shows us clearly that when we specify that a number of filters equals six, it doesn't mean
we actually have just six of this.
As you may feel like a number of filters equals six means we have six filters stack like this.
Here we have five and then six.
So we feel like we have just six stacked like this, which is not actually the case.
What happens is we have three does this three channels, and then each of our filters also have the
three channels, as you could see.
And so what we call a filter here is this three or rather this five by five by two.
We all right here.
Now, we've done the computation and we've had for this we repeat the same process.
So we take this for the are we repeat this, we repeat this, and then we obtain this next.
We do all this the same way up to this position.
And then we have this right here.
And that's why when we have six filters, we're always going to have six channels.
Then if you do five by five by three, and all that time six.
So if you have five by five times three, that 75, 75 times six should give you a total of 450.
And since for each of these filters, we add the bias that is we have an extra bias.
For each of these filters.
We have one, two, three, four, five, six biases.
So add in this plus six, we have 456 parameters to be trained.
So here we have 450 weights and six biases.
That said, we've understood why we have this six channels now.
How do we obtain this 60 by 60?
The way we obtain the 60 by 60 is by applying this formula, which we've seen already.
So here we just have the output equal 64 filter size five.
So we have minus five pattern, no pattern.
So pattern is zero stride one.
So we have 64 minus five and then plus one, this gives us 64 minus four, which is equals 60.
And that's how we have this output right here.
From here we move to the subsampling pooling layer.
For the pooling layer, we have these two parameters that we have the number of filters, and then already
we have the filter size, not the number of filters, the filter size.
And then we have the number of stripes to obtain the dimension for the pooling.
The formula is slightly different, obviously, because here we don't have the pattern, so we have
X minus F divided by x plus one, and then we'll leave from this to this feature map right here.
Notice how we still maintain the number of channels, but our.
Input feature map has been sampled for the particular case of max pooling.
If you want to understand how this works, let's be let's say we have this position, let's take this
position.
Let's take a position where we have some values.
Notice how as we pick this value, you see the max is 0.02.
So if you look around, look at this.
So we see here the max is 0.08 and then and so on and so forth.
So basically what we're doing is we're just simply sliding through the whole image.
And then for every since our canvas size is equal to we have a two by two kernel size here.
So for every four values, we are going to pick out one to represent them.
And in this case, this one is the max.
In some cases, we will instead take the average of this that's known as average pulling.
But for this max pooling, which is the most commonly used, we take the max of all these different
values that set to obtain this.
We have X that is in this case we have x equals 60.
So let's take this off.
X equals 60.
Minus f, f equal to divided by the stride or stride is two and then plus one.
So 60 -258 divided by two, 29 plus one gives us 30.
That's how we get this.
We still maintain the number of channels.
Here's another example showing even more clearly how this max pooling works or pulling in general works.
So if we have this input, so we're picking out just one of these supposed to be picking out just one
of this channels and we have this, we are going to have our channel two by two.
That's it.
And then what get what we get is output is zero.
Since the max of 000 is zero, we do we have a stride of two.
So notice how we've shifted my two positions, stride two and then the max here is two.
We move again.
Strike two.
Max now is two.
We move, We see Max is one move.
Max is zero.
And then you go to the next Max three and so on and so forth.
So that's how we obtain this new feature map right here.
Notice how we have this is five, ten, five, ten, and then here we have five, five.
So we leave from ten by 10 to 5 by five.
After this subsampling layer, we have the activation.
We've already looked at activation in the previous section.
We've seen the sigmoid and we've seen the value within the tank and we've seen the leaky rail.
So that said, we understand that and now we move to the next convolutional layer or filter size, equal
five pattern or pattern Stripe one Number of filters 16 number of parameters 2416 So you could take
this as an exercise to be able to show that the total number of parameters we have is 2416.
That said, we're going to have this output right here or we have the railroad added and then we have
this output.
So we have the output 26 or 26 by 26 by 16.
We call a number of filters dictates the number of channels right here and not the filter size is the
number of filters.
And then this 26 by 26 is gotten by using this same formula we've seen already.
From here we have another subsampling.
We've understood that already and then we flatten all this out.
So after doing the sub sampling, we have this 13 by turn by 16.
When you multiply all this should give you 2704 and this is what we call the flattened layer.
So we pass this to a flattened layer to obtain this.
Now this takes each and every value we have here in our feature map and then just simply places it in
this one dimensional output right here.
Then from here we have the dense layer, which we're used to working with already, and then we have
a thousand neurons, the output.
And finally we have 200 neurons.
In our case, we should have two since we're actually predicting whether it's a parasite or it's non
parasite.
So we should just have two.
Anyways, we understand all this now and we shall be ready to dive into the code before moving on to
the code.
Let's get to see what the future maps of a trained convolutional neural network looks like.
As you could see right here from this example from the Stanford website, we have this car which is
passed into a convolutional neural network and then its output.
We have it predicting a car.
As you can notice this, first layers actually serve as filters for low level features like the edges.
So you'll notice that this input or this feature maps from the first layers produce visually interpretable
outputs.
Now, you will notice also that as we go farther or deeper, we have this outputs which are less visually
interpretable and the focus more on high level features like the car parts, which parameters correctly
classify that this image contains a car?
And so the first layers are for feature extraction, and then the last layers are for classification.
Both subsections actually need each other as if you do feature extraction and you don't have layers
which are able to parameters correctly classify this image, then we will not achieve our goal.
And in the same sense, if we have a good classifier, but we get this kind of inputs directly where
we've not extracted useful features from them yet, then our classifier is not going to perform well.
You could also check this Covenant MIS demo by Andreas Capaldi, where he trains a model on the mixed
data set.
Here we have our model, the input column, pull, com pull and self max.
So here we have this on this data set and then we're having this passed in, as you could see.
Notice how in this first layers, the feature maps actually contain much more visual content as compared
to this final layers right here.
See, if you look at this final layers, you see that we have this feature maps which instead contain
content which permits us say, whether a particular input belongs to a particular class.
If you want to build convolutional layers with TensorFlow, you could make use of this TensorFlow Keras
model right here.
So that said, we're just going to come to the layers to that cars and then we pick layers and then
we'll find the conf 2d layer.
So there is a layer we're searching for double click on that and then here we go, we have the arguments.
That's what we pass in this layer.
The filters right here corresponds to the number of filters.
So let's take this off.
There is a number of filters within this already and F and then the kernel size corresponds to the filter
size.
From there we move to the strikes which take topple.
Let's take this off and check this out.
So here we have this tuple, actually.
And then what's important to note here is the fact that if you want to do striding of, say, one,
two, that is one two, then.
In the height dimension, your style is going to be equal one, and then the width dimensions try to
be equal to.
So if we have this feature map right here and we pass a colonel, we are going to be sliding.
And skipping two steps in this horizontal direction while when we come in or are we going downwards,
we are going to be skipping only one step.
So that's what this means.
Now, in the case where we are having exactly the same number of steps sliding horizontally and vertically,
then the striding like in this case, can just be given as equal one.
From there we have the pattern.
By default, the pattern is valid here.
We're told that for the pattern, if the pattern is valid, it means there's actually no pattern.
So we have zero pattern.
And then when the pattern is same, the result of the pattern, although we pad it with zeros to ensure
that the input dimension equal the output dimension.
Also note that this is only possible when the stride is equal one So that set or if we have a feature
map like this, let's say we have 63 by 60 and then we want to pass this to a conf layer to get an output
feature map.
And if one does our feature map to be the same dimension as the input that is 60 by 60, then all we
need to do is specify that the pattern is same.
So once we have this, the output will be the same as that of the input.
From here we have the data format.
Now note that there are generally two kinds of data formats.
That is, we have height.
So for an image, we have the height, width and then the channel.
So if we have 224 by 224 by three image, then we actually making use of this data format.
Now we could also use this format where we start with the channel.
So we have the channel by height and by width of.
And so here we have three by 224 by 224.
Note that by default we have the channel.
So by default, we have this first convention last right here.
But if you want to take this convention, all you need to do is to specify that you're working with
the channels first.
Then from here we have the dilation rate.
So we'll look at this GitHub repository by V2 where he uses animations to explain how convolutions work.
You could scroll down and you'll find the dilated convolution animation which when we click on we have
this.
So there we go.
We have this example in which the dilation rate is equal to.
So the way this dilation works is we have this kernel which initially had no spaces between his values.
So we had something like this, we had this three by three kernel.
And now what we do is we have this pieces.
All this holds between these different values.
And so now what we get is some sort of five by five kernel right here.
If we're working with a dilation rate, R equals three, then instead of a single whole year we are
going to fit in two other holes.
So we're going to have this.
We just have one, two and then we fit this, then we have one, two and then we fit this.
So that's how we, we build this out.
We have this and then that.
Now, to get the shape, we have one, two, three, four, five, six, seven.
So we have a seven by seven filter.
Now it should be noted that the dilated convolutions I use in problems where we want to keep increasing
the receptive field as we keep going deeper in the network while maintaining the number of parameters.
The next argument is the groups, and according to the documentation, this is a positive integer specifying
the number of groups in which the input is split along the channel axis.
This means that in this case, for example, we could break this up into three different groups.
So we have one, two and then two regroups.
Then each group has its own group filters and then the output is a concatenation of all the group results
across the channel axis.
From here we have the activation, which we've seen already, and then we'll say whether we're going
to use the bias or not.
We have this kernel that is the weight initialization and then we have the bias initialization.
We have this regular rises which will see subsequently and then we have the kernel and bias constraints.