-: Hello and welcome to this tutorial.
So now that we have a brain and a body,
we can make the AI.
Of course, we're going to assemble them
and you're gonna see how now things
are all gonna make sense.
You're gonna understand why we had
to make some classes
or more specifically, the purpose of making these classes,
and mostly you're gonna get intuitive sense
of how you can play with objects
to create new objects, bigger objects.
And as you understood,
we already created two classes:
the brain and the body.
So then by creating some objects of these two classes,
well, we can make a bigger object,
which will be the AI.
And that's exactly what we're gonna do now.
We are gonna make the AI by assembling the two classes
that we created, that is the brain and the body.
So let's do this.
It's gonna become super intuitive now.
I'm going to introduce a new class,
which of course, I'm gonna call AI
because now we're ready to make the final AI.
And right here, I'm going to start with the init function.
And what is this init function going to take?
It is right now that things will make a lot of sense.
Well, first, we get the inevitable self
with the object.
But then, the two arguments are gonna be nothing else
than the brain and the body.
That's the two elements that we need to build an AI.
We need a brain, the neural network
and a body, which will play the action with softmax.
And so now very simply what we have to do
is defining the variables of our AI object
because right now, brain and body are just arguments.
So let's do this.
We have to make two variables obviously.
The first one is self.brain,
which will be equal to the brain argument
but which later will be a brain object created
from the CNN class.
And then the second variable is self.body,
which will be equal to the body argument right here.
But which in the future will be,
of course, an object of the softmax body class.
And so now as simple as that,
thanks to this pretty awesome structure that we made here,
we built an AI.
Not trained yet, not intelligent yet
but still, we have a brain and a body.
So that's perfect, and now the only thing
that we have to do left
is make a big forward function
that will do the whole propagation.
Since now our AI is assembled,
well, we're not gonna use separately
the two forward functions,
the one of the brain and the one of the body.
We're gonna make a big forward function,
which will be our next function,
which will take the images as input,
then we'll propagate the signals in the brain,
and for this, we will, of course,
use the first forward function,
and then once we get the output signals of the brain,
we will forward these output signals into the body
with the forward function here
that will use a softmax technique.
And then eventually, we will return the actions to play.
And that is just now
that we can make this big forward function
because we have assembled the brain and the body.
And so we're not gonna call this next function forward,
we're gonna use the call function,
which is kind of like the init function
but that will call the two forward functions here
from the brain and the body to propagate the signal
from the very beginning with the input images
to the very end with the action to play.
And that's why the next function we will make now
is this call function
that will combine the two forward functions
of the brain and the body.
That's the only thing we have to do
and then we will have our AI ready.
So let's make this final step in the next tutorial.
And until then, enjoy AI.