Hello and welcome to this pipe and to Torro now we have to define the five variables of this function
that is the three convolutions and the temporal connections.
So let's start with the first one.
Convolutional one applies convolution to the input images so that's the original images and now you're
going to see how everything will become so simple to create this convolution.
Well what we have to do is actually create a subject of some specific class and this class is taken
from and then and then the classes come to the to because we're working with 2D images and now as you
can see we need to put several arguments.
First one is in channels.
Let's put it in channels.
The second one is out channels.
The third one is Kerno size and the rest of them are stride padding the dilation groups and bias.
And we have different values for all these ones.
So we're not going to but them we're going to keep the default values.
But what's important is these three arguments in channels and channels and kernel size and so do I guess
what they correspond to.
Well very simply in general correspond to the input of the convolution and all channels correspond to
the output of the conclusion.
So what is it going to be.
Well very simply that's going to be the number of channels in our images.
And actually we are going to work with black and white images because basically we don't colors to recognize
the monsters.
The AI is totally capable of recognizing the monsters in black and white.
So we don't see the colors at all just recognize them by their shape.
Therefore we're going to use one channel so one channel is when you have black and white images and
three channels is when you have called images.
And therefore since we're working with black and white images in channels it's going to be equal to
one then our channels so our channels it's going to be equal to the images you want to have in the convolutional
there which is the output of this constitution one.
And so basically this is equal to the number of features you want to the text in your original images
because who will create one image per feature we want to detect because basically you know how it works.
We applied one feature detector to the input image to detect a specific feature in the input image and
therefore the number of output images here is the number of features we want to detect.
So now the question is how many features do we want to detect.
Well a common practice is to start with 32 feature detectors and so that will lead us to 32 percent
images in this first convolutional layer so the input is one black and white image a real image and
the output in the first convolutional there is 32 processed images and by processed I mean of course
that the conclusion was applied to the input image to get 32 new images with detected features.
And then we need to specify a kernel size which is nothing else than the dimensions of the square that
will go through the original image.
And in common practice we use either to buy two or three wide three or five by five.
And for the first one we're going to use a five by five feature detector that is a feature detector
that will have five by five 10 engines.
And then we will reduce the size of this kernel for the next convolutional layers.
And speaking of it this is exactly what we're going to do now.
We are going to copy this to define the second convolution and therefore I'm basing that here and now
it's very funny and very easy it's like a domino.
The input channel of the second convolutional layer is the output channel of the first convolutional
there.
So this number of output 32 Here is the same number of inputs 32 here.
And that's because we have 32 images in the input convolutional layer of the second convolution.
And so the second convolution is applied to this second convolutional layer to return a third convolutional
layer.
And so now the question is how many new images do we want.
Well same that create 32 new images 32 is actually a very common number in convolutional neural networks
if you look at the architectures you will find 32 in many of them.
And then for the kernel size Well we need to reduce the kernel size that is the dimensions of our feature
detector.
And so now we're going to go from five to four or even three and then we'll go even smaller.
All right so our second convolution is ready.
It takes as inputs 32 process images.
Each one in a first feature of the original input image and it creates 32 new images.
Thanks to this reduced dimensions of the feature detector.
And so now let's push this even more.
So I'm copying this and pasting that here to create a third convolution to detect some features.
And so now that's the same the input channels.
Here is the number of input images at the left of deconvolution connection and that is the number of
precess images that went to the right of the previous convolution connections.
That's 32.
Therefore we keep sorry to hear.
That's perfect.
And now the question is again how many new images do we want to detect.
We are going to take now 64 and therefore 64 outputs precess images.
And of course now we take a smaller kernel size and we're going to take two.
And so that's a very classic architecture of a convolutional there and it's very efficient to have a
high level of feature detection inside images.
All right and so now that we have our three convolutional there's are to our three convolution connections
here.
Well now it's time to get our toothful connections that I remind we'll take this huge vector that we
obtain after flattening all the 64 times 32 times 32 again images that we got from all these convolutions
so we flattened all the pixels of these images and we can one huge vector that will become the input
of a new fully connected neural network.
And so that's when we have to make these connections between first this huge vector and a hidden layer
and then a second full connection between the hidden layer and the output they're composed of the output
neurons.
Each one corresponding to a cube value of the possible actions.
So let's make these two connections.
You know how to do that.
That's exactly what we did for the self-driving car.
So let's do that again.
Well first we take our Maggio then we take the Lynnie our class because again the connection we create
is an object of the ruling class.
And then in parenthesis.
Well that's the same for put the input features that is the number of them then the output features.
And so the input features for the first full connection what is it going to be.
Well that's going to be equal to the number of pixels there are in this huge vector change after flattening
all the process images after the three convolutions.
And so what does this number.
Well actually there is a trick here.
This number is actually hard to get.
We actually need to make a function to compute that number.
We don't have a variable that will get us this number.
We have to compute it and therefore what we're going to do now.
And now it's very important to understand the mindset of programming that we must have and trying to
bring to you the mindset that is what you must be thinking right now to do to overcome this obstacle
because the first time you might say hey I don't have this number of neurons in the Flaten vector.
What should I do.
I'm stuck here.
Well no actually because what you can do now is simply input any name here that will represent the number
of neurons so uncommon that number neurons number of neurons and then we will simply make a function
that will return and this number of neurons variable.
This number of pixels we're looking for.
So we can totally do that we can totally put this very vocal of course will get a warning because it
doesn't exist yet but we will create it afterwards with a function.
And we are totally allowed to do that even if the function comes afterwards.
That's a typical programming thinking you must have when you get that kind of obstacle.
Well you can make a function to get what you're missing.
All right and then our features and our future.
That's the number of neurons in a hidden layer and that this time is up to you.
That depends on the architecture of the new network you want to create.
And so a good number would be not a small number.
So for example 40 neurons might be fine.
We can try to increase that.
If the training is not too slow you can try to increase that.
Maybe that will improve the predictions but let's start with 40 maybe we'll increase that afterwards.
All right that's it for the first full connection then we'll copy this paste that here for the second
full connection that is the connection between the hidden layer and the output layer.
And so the features here becomes the out features of the previous layer and that is 40.
So here we can put 40.
That's of course the number of neurons in a layer.
And our future is going to be equal to the number of output neurons there should be no neural network.
And since each output neuron corresponds to one new value and one Cuvee and response to one action while
the number of output neurons here is of course the number of actions and we have one variable for this
which is number actions and therefore here input number actions and there we go congratulations.
We did find the architecture of our neural network our neural network is composed of three convolutional
layers and one hidden layer.
All this in one big CNN and this CNN will detect features in the game so that the AI will know where
it has to do where it has to go and where it needs to shoot.
So then we go for this step.
That's a first very important step done.
Now we're going to move onto the next step which is of course to get this number of neurons that is
still missing.
That's actually why we have the warning here and the phone number neurons but no worries.
Now we will make a function that will return the number of neurons in this huge vector and we will put
that number in a variable that will call a number of neurons.
So let's do this in the next tutorial.
That's our next step.
And until then enjoy AI.