WEBVTT

00:00.480 --> 00:03.030
-: Hello and welcome to this Python tutorial.

00:03.030 --> 00:04.710
All right, so we just made the brain

00:04.710 --> 00:06.450
and now let's make the body.

00:06.450 --> 00:09.570
So as you understood, the body is the part where we define

00:09.570 --> 00:11.400
how the actions are gonna be played.

00:11.400 --> 00:13.860
Like what happens for real human body, you know,

00:13.860 --> 00:17.160
you have the brain that send the signals to the body

00:17.160 --> 00:19.020
and then your body plays the action.

00:19.020 --> 00:20.160
Well, here that's the same.

00:20.160 --> 00:23.100
We have our signals coming from the brain.

00:23.100 --> 00:26.250
We get the output signal with the forward function here.

00:26.250 --> 00:28.890
You know, first what happens is that we get the images.

00:28.890 --> 00:31.440
The images go into the eyes of the neural network

00:31.440 --> 00:33.810
composed of the three convolutional layers,

00:33.810 --> 00:35.670
and then with the fully connected layers,

00:35.670 --> 00:38.370
we get the output signal from the brain,

00:38.370 --> 00:40.140
which contains the Q values.

00:40.140 --> 00:42.870
But then, this output signal should be forwarded

00:42.870 --> 00:45.630
to the body and the body will play the action.

00:45.630 --> 00:47.190
And so that's exactly the part

00:47.190 --> 00:48.840
that we're gonna take care of right now.

00:48.840 --> 00:52.860
We're gonna implement the way the body will play the action

00:52.860 --> 00:56.550
and the way it will do it is with a Softmax method,

00:56.550 --> 00:58.440
exactly like for the self-driving car.

00:58.440 --> 01:02.250
I insist that the Softmax method is highly recommended

01:02.250 --> 01:05.520
for playing in action with the body of the AI

01:05.520 --> 01:08.310
and therefore, that's the one we're gonna go for.

01:08.310 --> 01:10.860
But as opposed to the self-driving code,

01:10.860 --> 01:11.970
we're gonna make a class.

01:11.970 --> 01:13.020
And this class will, of course,

01:13.020 --> 01:16.350
correspond to the body of the AI.

01:16.350 --> 01:20.130
And therefore, let's start by introducing class here.

01:20.130 --> 01:21.300
That's where we're gonna go.

01:21.300 --> 01:25.500
Softmax body, like this.

01:25.500 --> 01:27.300
I don't wanna call it Softmax only

01:27.300 --> 01:31.830
because Softmax is a class of PyTorch from the nn.Module.

01:31.830 --> 01:33.240
So it's dangerous to call it this way,

01:33.240 --> 01:35.310
therefore I'm calling it Softmax body

01:35.310 --> 01:38.640
and now, it's very clear that our CNN,

01:38.640 --> 01:41.640
Convolutional Neural Network is the brain

01:41.640 --> 01:45.330
and Softmax body is the body of the AI.

01:45.330 --> 01:50.330
So Softmax body, and let's inherit from the nn.Module.

01:52.050 --> 01:53.640
I don't think we're gonna use it,

01:53.640 --> 01:56.250
but anyway we can still inherit from it.

01:56.250 --> 01:58.470
You know, in case you want to improve

01:58.470 --> 01:59.880
this Softmax body class

01:59.880 --> 02:02.220
and wanna use some tools from the nn.Module,

02:02.220 --> 02:04.800
while you will be able to do it with the nn.Module.

02:04.800 --> 02:06.240
But at this point, I don't think

02:06.240 --> 02:08.670
we'll be using any of the nn.Module.

02:08.670 --> 02:13.530
So then colon, and let's go inside the body.

02:13.530 --> 02:14.730
All right, so first as usual,

02:14.730 --> 02:17.700
we're gonna start with our _init_ function

02:17.700 --> 02:22.140
to define the variables of the future body objects

02:22.140 --> 02:24.120
that is the bodies of the AI.

02:24.120 --> 02:26.970
And actually, as for a human body,

02:26.970 --> 02:30.150
a parameter that can define it is the temperature.

02:30.150 --> 02:32.610
And actually that's gonna be the only temperature

02:32.610 --> 02:34.440
so it's a simple body, but still,

02:34.440 --> 02:37.350
using this temperature parameter will do a lot for us.

02:37.350 --> 02:39.180
Okay? But before the temperature,

02:39.180 --> 02:43.320
let's not forget the self for the objects for the bodies.

02:43.320 --> 02:46.770
And now we can input the temperature T,

02:46.770 --> 02:48.240
which is the same parameter

02:48.240 --> 02:51.000
as the one we use for the self-driving car.

02:51.000 --> 02:52.860
Okay? And then colon,

02:52.860 --> 02:55.920
and let's define our variables.

02:55.920 --> 02:59.700
So, since we inherit from the _init_ module,

02:59.700 --> 03:02.190
we're gonna use the super() function again

03:02.190 --> 03:03.570
and so, let's be efficient.

03:03.570 --> 03:08.570
Let's copy this and let's paste that right here.

03:09.600 --> 03:10.800
And of course, let's not forget

03:10.800 --> 03:14.280
to replace CNN here by Softmax body.

03:17.400 --> 03:18.233
There you go.

03:18.233 --> 03:20.310
Now, I suppose that might become a reflex for you

03:20.310 --> 03:22.530
to use the super() function at this stage.

03:22.530 --> 03:25.200
And then, what we have to do is of course,

03:25.200 --> 03:30.120
set our temperature variable with self.T

03:30.120 --> 03:34.080
and that will be equal to the argument that will be input

03:34.080 --> 03:37.170
when creating an object to Softmax body class.

03:37.170 --> 03:39.390
I remind that whenever you create an object

03:39.390 --> 03:40.980
of the Softmax body class,

03:40.980 --> 03:42.660
you have to input the arguments

03:42.660 --> 03:45.690
that are in the _init_ function, and therefore that is T.

03:45.690 --> 03:48.480
And then, the variable of your object attached

03:48.480 --> 03:51.780
to your object self.T will be equal to this T

03:51.780 --> 03:54.660
which is the argument that you will input.

03:54.660 --> 03:57.030
All right, and now that's it for the _init_ function

03:57.030 --> 03:58.710
that's actually all we need.

03:58.710 --> 04:01.080
So, I guess we're ready to move on

04:01.080 --> 04:04.080
to the next function of the Softmax body class

04:04.080 --> 04:05.790
and this is gonna be the last function.

04:05.790 --> 04:09.060
There only two functions, the _init_ function

04:09.060 --> 04:11.700
and the next one that will implement in the next tutorial

04:11.700 --> 04:14.550
which will be the forward function and why forward?

04:14.550 --> 04:16.830
That's because right now, we have to forward

04:16.830 --> 04:18.840
the output signal from the brain.

04:18.840 --> 04:19.673
That is, you know,

04:19.673 --> 04:21.780
the Q values contained in the output neurons

04:21.780 --> 04:25.800
of the output layer to the body which will play the action.

04:25.800 --> 04:28.920
So we are forwarding the output signal from the brain

04:28.920 --> 04:31.170
to the body that will play the action.

04:31.170 --> 04:32.880
Move forward, go left, go right,

04:32.880 --> 04:36.030
turn left, turn right, or shoot.

04:36.030 --> 04:38.670
All right, so let's do that in the next tutorial

04:38.670 --> 04:40.533
and until then, enjoy AI.
