Hello and welcome again to Mudgal to do them we will now get us ready to start the implementation of
our AI.
And as usual the first thing that we need to do is set the right father as working directory.
So let's do this now so that we can move on to what's more interesting.
So as usual I start on my desktop then I go to my artificial intelligence that folder then module to
now do.
And there we go to the that we have to set as a working directory.
So let's do this now we click on these two but here then restart kernel and then yes.
And here we go.
We now have the right folder as a working directory.
So now you can see we have four foules well actually three thousand one folder in this working directory
folder.
So let's start with the first one.
The first one is a either way.
That's of course the file that will contain our artificial intelligence and that's nothing else than
this file here.
That is the AIW I fell in which will implement everything that is related to building an AI and especially
building an AI AI with the deep convolutional.
Q learning more.
So basically that's where we'll have the big adventure.
Then we have some other Feltz we have the second floor which is experience we play that way.
And so this time I put experience to play separately just because we already implemented it and now
we want to focus on what's new.
And trust me we have a lot of new things to do with this new artificial intelligence because not only
we want to build an AI AI but we want to build any AI to beat doom.
So you can imagine that this will require some quite advanced code so no worries.
We have a big code waiting for us and you will learn a lot of new tricks.
That's why this experience replay trick that you already know and that I remind improves a lot the training.
Well let's put it separately in this experience we played that I found so that we can now focus on all
the new concepts techniques and tricks that are waiting for us.
All right and then we have the image pre-processing that I found.
So that's another python file which will take care of pre-processing or images because you know this
time or I will have eyes and that's because the input states are no longer encoded by a vector.
But this time the input states are the images.
So the first layer of the big neural network that will make will be the eyes and that will be the convolutional
layers of the convolutional new network to make sure these images can be accepted as inputs of the convolutional
neural network.
Well we need to preprocess them and so this fout will take care of pre-processing these images so that
they can go into the neural network.
And so I separated this valve because this is not directly related to AI.
And again we want to keep the maximum of our brain in our memory and our focus on everything that is
related to AI.
So we are putting this separately so that we can preprocess even just in a flash light and save some
energy for the rest.
You can have a look at it if you want and you also have the deep cores.
Well you can have a look at the practical tutorials.
We talk about image processing.
Well here again we really want to focus on the eye.
Trust me we have a lot to do and eventually the last folder.
Well that's the videos folder.
So right now this folder is empty as you can see.
But when we execute the code some videos of the apelin doom will be added to this folder.
So that will be very exciting because we will see on some videos how well the AI is doing.
So we will literally see the AI killing the monsters and trying to run towards the goal.
You're going to see this will be pretty exciting.
So of course the first videos will be very bad because the eye will not be trained much yet and so it
will get killed very fast but then you will see that as the training is progressing well the eye will
get better and better and eventually it will manage to kill some monsters not getting killed.
And hopefully we will be able to make it reached to go.
All right so let's go back to our AFL which is just one.
And as you can see I already took care of importing all the central libraries and packages that we need
to play them.
So let's quickly have a look at them one by one we have of course none by because we'll be working with
arrays.
That's inevitable.
Then we have talked of course because we're implementing the AI with a torch.
Then we have the torch that and a module which contains all the tools to implement a neural network.
So for example the module will contain the convolutional layers that will be part of our future neural
network.
Then we have that and then that functional package which has a shortcut and that contains all the functions
that are used in a neural network.
So typically the activation functions will be using some rectifying activation functions but also some
pooling function for the company neural networks and all these functions are contained in functional.
Then we have up to him which is of course for optimizer I think we'll be using an addon optimizer and
this optimizer is contained in up to him and then the best of the best by torche the variable class
from the autograph module and that's all the power of it all because that's what contains the dynamic
graphs allowing to perform very fast computations of the gradients even the gradient of composition
functions.
So we will definitely be using it.
As for the soldier in car.
But trust me for Dume we will be needing it very bad.
I guess that's all for the essential libraries then we need to import some packages related to open
agent and doom.
So of course we import Jim then we import some wrappers module of the gene library and one of these
wrappers is Kyp wrapper.
So that's basically to import all the tools and environments of Jim.
And finally we have this package that we need to import and which is directly related to do.
And that's the actual space and two discrete of the doom wrapper that basically contains the environment
of doom and more specifically the actions that can be played.
The number of actions for this specific game we're going to play.
And I remind that there are six sections move left move right turn left turn right move forward and
shoot attack.
All right so that's basically what you need to import for doom.
And then finally we of course need to import our two internal files experience.
We played a pure Whyfor experience.
We play an image pre-processing to preprocess the images that are nothing else than the images of the
screen.
When playing the game and these images will be pre-processed converted into non-payers reshaped to a
certain format and then they will go to the new one that was the convolutional on one that was all right.
So I guess now that we were ready to start the big implementation of this AI and now it's very important
for me to tell you that that leads me to the very important point of this Munjal is that since you know
I told you we have a big implementation waiting for us.
Well in order to not get lost in all this we need a good structure.
And so I already highlighted the structure.
We will be implementing this in two parts.
The first part will be about building the AI.
So that's where we will make the brain of the ai ai in the brain.
As you understood it's nothing else than the neural network.
You know this big CNN composed of some convolutional layers and then some fully connected layers to
predict the outputs.
There are still the key values and then we'll make the body of the AI.
And that's the new representation I'm bringing to you.
And that's again not to get lost.
You will see that the further we progress with the code the more we will see the structure and everything
will make sense in the end.
And to make sure that makes sense we need a representation of the AI.
And basically this first part of building the AI will be composed of three sections.
First section will be about making the brain that is the neural network.
The second section will be about making the body.
And I'm calling it the body because this is the part that will tell the AI how to play the action.
So you know first you have the brain that detects the images and predicts the q values.
But then you need to specify how the AI should play the action and that it does it with its value like
a human body would do.
So the body will be the part where we will specify the method of playing the action.
So for example with our self-driving car the brain was a neural network we made and the body was how
the action was played.
That is with the Saft next method.
And here that's the same we're going to make a brain and we're going to make a body which will play
the action.
I will let you find out.
But the key point in all this is that we will have a very structured code so that not only you can take
a step back and really understand what's going on but also you will be able to use it as a framework
whenever you want to build the AI for other purposes.
All right.
And after building the.
In part one we will move on to part 2 which will be about implementing the convolutional here and there
again will have different sections.
And one of them will be of course to train the AI.
So I can't wait to dive into it now.
We're going to start with one obviously and we're going to start by making the brain of our AI.
So I can't wait until then.
AI.