Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
Hello and welcome to the second big part of this implementation training the brains.
2
So we have just smashed part one creating the brains and now we're going to tackle part to training
3
the brains.
4
So this training implementation will be broken down into two big steps.
5
First step will be to update the weight of the neural network of the discriminator and then the second
6
step will be to update the weight of the new one that work of the generator.
7
And then if we want to break down this process into some more steps.
8
Well that's how it goes in the first big step.
9
Updating the weights of the discriminator we will want to train the discriminator to see to understand
10
what's real and what's fake.
11
So we will first train it by giving it a real image and we'll set the target to one because one means
12
that the image is accepted and then we'll do another training by giving it this time a fake image and
13
setting the standard target to zero because zero means that the image is not accepted.
14
So this first big step can be broken down into two steps.
15
First training the discriminator with a real image and then training the discriminator with a fake image
16
and this fake image will be of course a fake image created by the generator.
17
And then in the second step of the training that is about the weight of the neural network of the generator.
18
Well we'll take the fake image again which will be in one step of the loop then we'll feed this fake
19
image into the discriminator to get the output which will be a value between 0 and 1 the discriminating
20
value.
21
But then we'll set a new target to 1.
22
The target will be equal to 1 always and will compute the computerless between the output of the discriminator
23
the value between 0 and 1.
24
And this target always equal to 1 then be careful.
25
That's the key thing to understand will back propagate this error not back inside the discriminator
26
but back inside the generator.
27
That's the key thing to understand the error is the error between the prediction of the discriminator
28
and the target equal to one but will back propagate this error back inside the neural network of the
29
generator.
30
And then once we do that will applies to kesa great in the sense to date the weight of the neural network
31
of the generator.
32
All right.
33
So we have given a teaser of what's going to happen in the second phase of training the brain.
34
So let's tackle the second phase and let's start right now.
35
All right.
36
So we have to start by getting a criterion that will measure the error of prediction that will be of
37
value between 0 and 1 because that will be the prediction of the discriminator the discriminating number
38
between 0 and 1 and a ground truth that will only be 0 or 1 0 means fake and 1 means real.
39
So let's do this.
40
That's our first step.
41
We create a criterion object criterion object that will be an object of the b c the last.
42
So if we go to the PI torch documentation we can see that the B C class is actually given by this formula.
43
And so this is a special kind of less perfect to train at this adversarial networks and busy means binary
44
Krus entropy.
45
So that's the last we'll be using for our Just again.
46
But we see that it is also used for our encounters.
47
But the most important thing is that the target should be numbers between 0 and 1 and that will be the
48
case for TCN.
49
Because the targets will either be zero when we want to try to discriminate or to recognize a fake image
50
or one.
51
When we train the discriminator to recognize a real image.
52
So basically us and then we just need some parenthesis.
53
All right so perfect.
54
We have our criterion and now we need to optimize one optimizer for the generator and one optimized
55
for the discriminator.
56
So we'll start with the optimizer of the discriminator.
57
And this time we're not going to get it from.
58
And then the end module but if we have a look again at our libraries that we imported.
59
Well as you can see here we imported towards start up.
60
And we gave it the shortcut name up to him to simplify.
61
But that's from which we will import our optimizer object.
62
So here we go optimize Riddhi equals Optum dot and we'll get the atom optimizer which is a highly advanced
63
optimizer for stochastic great in the sense.
64
Okay.
65
And now this time we have to put some arguments the first argument we need to input are the parameters
66
of our neural network to one of the discriminator and to get them we're going to take our neural network
67
objects of the discriminator that we called Net D.
68
So net D.
69
And then that and then we get the parameters this way with some parenthesis then we specify a learning
70
rate and the argument for that is are and will show the value of our point 0 2 and then the third argument
71
we need to specify the beta's parameters and we're going to improve them this way the name of the argument
72
is better.
73
And it's actually a couple of two values that we have to choose.
74
And if we go to the pie torch documentation again well we see that for this Adam optimizer that these
75
bettors are actually coefficients used for computing running averages of gradient and square.
76
So we're just going to pick two values now again coming from experimentation and we'll choose 0.5 and
77
point nine nine.
78
Great.
79
Perfect.
80
We have the optimizer of the discriminator.
81
And now let's get the optimizer of the generator.
82
So since we're going to have the same parameters the same learning rate and the same betas.
83
We simply need to change the name of the optimizer.
84
And of course we're going to call the optimize of the generator optimizer G which will also be an atom
85
optimizer with the same parameters except of course for the parameters of the neural network.
86
So here we just need to replace Nat d by Najee and perfect.
87
Now we have zero Pretorian attached to the PC plus the optimizer of the discriminator and the optimizer
88
of the generator.
89
And that's good news because basically we're ready to start the big loop of the training that is the
90
loop over the different epochs.
91
So we're going to have 25 EPOC and therefore this loop is simply going to be for Epoque in range 25
92
and in.
93
And this way the epochs will go from zero to 24.
94
We'll have 25 epix.
95
You're welcome to try more e-books if you want to try to have some even better images.
96
But I can tell you that already with 25 bucks we'll get some great images.
97
And also it's important to understand is that in each of these 25 bucks we'll go through all the images
98
of the dataset we'll go through all the images of the dataset twenty five times.
99
All right so now we're directly going to start with a new for loop that if you've listened to the last
100
sentence I've just said it's going to be the nucleus we'll go through all the images of the dataset.
101
Therefore the second for loop is going to be for I which will just be the index of the loop and then
102
data that will contain a million batch of images.
103
We will go through all the images of the dataset mini batch by mini bitch.
104
That is what it means.
105
And data will be one of these mini batches.
106
So we're breaking the data the whole data set of all the images in too many batches and data will be
107
each of these different mini batches.
108
And so now to get these different mini batches we're going to use data loader and we're going to use
109
the enemy rate function to get these separate mini batches of the dataset.
110
And so inside and emirate's we have to put our data loader which will get us the mini batches but then
111
we also have to specify where the index of the loop is going to start from that is where I is going
112
to start from.
113
And I will start from zero.
114
So I'm just adding 0 here and there we go.
115
We are ready to start the big two steps of the training.
116
So we'll do these big two steps in two separate tutorials.
117
The next one will be about updating the weights of the neural network the discriminator.
118
Then the next tutorial after that will be about the second big step about the update of the weight of
119
the new work of the generator and then we'll have the last final exciting tutorial to print the classes
120
save the real images save the fake images and watch the final results.
121
So be ready for all this.
122
And until then enjoy computer vision.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.