All language subtitles for 055 GANs - Step 9-en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1

Hello and welcome to this new tutorial.

2

So here we are ready for the big first step of the training that is updating the weight of the neural

3

network of the discriminator.

4

This big first step we're going to tackle it in three subsets.

5

The first step is to train the discriminator with a real image of the data set.

6

The second step is to train the discriminator with this time a fake image generated by the generator.

7

And finally will back propagate the total error which will be the sum of the errors of these two previous

8

trainings.

9

So now I have a question for you.

10

Why do we have to do a training of the discriminator with both a real image of the dataset and a fake

11

image generated by the generator.

12

And the answer is that simply because we want to train the discriminator to see and understand what's

13

real and what's fake and therefore to make the discriminator understand that well we need to give him

14

the two different ground tricks we need to give him the ground truth of what's real and the ground truth

15

of what's fake.

16

So the ground truth of what's real is of course the real image and the ground truth of what's fake is

17

of course the fake image generated by the generator.

18

So if you understand that well it will be very easy these two subsets will appear very natural to you.

19

And so now if you're ready let's do these three steps.

20

But before we start with the first obstacle is training the discriminator with a real image of the data

21

set to train it to understand what's real.

22

Well we need to initialize the gradient of the discriminator with respect to the weight to zero and

23

to do this it's very simple we take the neural network of the discriminator which we called Nedney then

24

we added that and then we use the zero underscore grad function and that will automatically initialize

25

to zero the gradients with respect to the weights.

26

So that's done and now we can move on to the first subset that is training the discriminator with a

27

real image of the day set.

28

All right so the first thing we need to do is get the real images.

29

Why do I say real images.

30

That's because we're going to get in fact a mini batch of real images and that's because a neural network

31

actually accept as inputs some many batches of single inputs like single images and therefore we have

32

to work with many batches but that's perfect because we already iterated through some many batches that

33

we got with a loader.

34

So we already have these mini batches.

35

And therefore as you will see right now it will be very easy to get these in any batch of real images.

36

So this input many batch I'm going to call it real and it's actually going to be the first element of

37

our mini batch data.

38

Right now we're dealing with a specific mini batch which is data and data is composed of two elements.

39

The first elements are the real images themselves and the second element are the labels.

40

But we don't really care about the labels right now.

41

So I'm just getting the first elements and to do that to get the first element of technique is to add

42

a come here and then an underscore to specify We actually don't care about the second element and then

43

equals data.

44

All right so perfect.

45

We have our input but it is not yet an accepted input of a neural network in by torche by torche neural

46

networks only accept the input in Torch variables and I remind that a torch very well is a highly advanced

47

variable that contains both a sensor and a gradient.

48

Right now we have to sensor because real is actually a sensor of images.

49

But we need to wrap it into a torch very well to associate it with a gradient and to do this we're going

50

to introduce a new varry Walters we're going to call input because this will be the input of the neural

51

network and this input is going to be an object of the variable class which will take his arguments

52

are real input images in them in batch and now are input images are not only in too many Bache but also

53

in a torch variable.

54

So now we're allowed to feed the neural network with this input.

55

But before that we will get the target.

56

And now the line of good I'm going to type is very very important at this stage.

57

You're going to try to guess what the target is going to be.

58

We're going to have to target for the different training this training and the following training.

59

And so try to guess what exactly these targets are going to be.

60

So I'm going to introduce here a new target.

61

So now according to you what is this target going to be.

62

Well since we are training the discriminator with a real image of the data set to train him to under

63

one and see what's real what is a real image.

64

Well for each of the real image of the million batch Well we need to set the target to one white one.

65

That's because remember zero corresponds to rejection.

66

The image is rejected by the discriminator and one corresponds to acceptance.

67

The image is accepted by the discriminator and therefore we need to set the target to one because we

68

need to specify to the discriminator that the ground truth is actually one to ground truth is the image

69

is real.

70

So the image gets a 1.

71

And that's why right now we're going to create a torch sensor that is going to have the size of the

72

mini match.

73

And that is going to be composed of only once we will have a one for each of the input image of the

74

mini batch.

75

So there we go.

76

Let's do this.

77

We need to take the torch library and then very simply we have a great function that is called.

78

And that will create this sensor only once.

79

And as you might guess what we need input in this one function is actually the size of the sensor that

80

is how many ones do we want and we want as many ones as they are real images in the real input mini

81

batch.

82

So how can we get this size of the input batch.

83

Well we just need to take our input many batch and then add that and then add size with some parenthesis

84

input that size contains the size of the mini batch that is contains the number of real images of the

85

input many batch and therefore also the number of ones the target should contain.

86

But as you notice I said contains.

87

And to get the actual number we need to take the first index of this element in that size which is zero.

88

So input that size of index 0 will return you the size of the mean bitch.

89

Perfect.

90

And now question Are we allowed to move onto the next step.

91

No we're not.

92

The reason is we have to wrap the target in a torch viable.

93

Indeed we're going to compute some gradients of the target as well and therefore we need to attach this

94

target sensor to a gradient inside a torch variable.

95

So I'm going to take my variable class again and I'm going to put everything inside some parenthesis

96

so that target becomes an object of the variable class taking his argument this torch and sort of once

97

right.

98

And now we have the inputs and the target.

99

So we know what to do next.

100

We need to get the outputs.

101

So let's do this let's get the output well to get the output.

102

Actually pretty fun and very simple.

103

We'll first introduce a new variable for the output output and we are going to call our neural network

104

of the discriminator so needy and we are going to feed this neural network with of course the inputs

105

the input which is a torch Vrable of a mini batch of real images.

106

And so inside here I just need to input Well input.

107

All right.

108

So through the main metal module that forward propagates the real input images of the mini match inside

109

the neural network of the discriminator to get for each of these real inputs images the prediction of

110

the discriminator whether they should be accepted or not.

111

So I remind that for each of these real images the output that is a prediction is a number between 0

112

and 1 and a number close to zero means that the discriminator will reject the image and a number close

113

to 1 means that the discriminator will accept the image.

114

So that's the discriminating number and it's a number between 0 and 1.

115

All right perfect.

116

And now that we have target full of ones and the outputs.

117

Well guess what we're going to get.

118

Well of course we're going to get the error.

119

The first error coming from this first training of the discriminator with the real image ground troops.

120

And so this specific first arrow we're going to call it e r r d.

121

Because we're also going to have an area for the generator but much later that is in the second big

122

step of the training.

123

E r r d.

124

And since this area corresponds to the real ground truth.

125

Well I'm going to add here and underscore and real.

126

All right.

127

We are the real and now to get this error.

128

Well what should I take I should take my criterion.

129

We have a new object that will compute the last error for us.

130

It will compute the last area between the output and the target.

131

So that's perfect.

132

And as you might guess inside this concern we need two inputs.

133

First the output and second the target.

134

And there we go.

135

We have our first last error of the discriminator the one corresponding to the training of the discriminator

136

with the real images to train it to understand to recognize what's real real images perfect.

137

And now we're ready to move on to the second step of the training of the discriminator.

138

It is the training with this time a fake image generated by the generator.

139

So this time we're training the discriminator to see and understand what's fake.

140

That is to recognize fake images.

141

So we're going to do the same process as we did here.

142

We're going to get first the input then the target then the output then this will generate a loss which

143

will call our already underscore fake and we'll be done with this second step.

144

And then finally we'll get the all error as to some of these two errors are already real and are fake.

145

And then we'll do the big back propagation of this total error.

146

Back inside the neural network of the discriminator.

147

So let's do this let's tackle this second training with the ground truth of the vague images and let's

148

start right now by getting the inputs.

149

So it's actually not that direct according to you.

150

How are we going to get the input which this time should be a mini batch of fake images.

151

Well if you remember what we did here when defining the architecture of the generator.

152

Well remember that the first inverted convolution takes as input a random vector of size 100.

153

And that I remind is because the generator is like an inverted CNN.

154

And since CNN takes as input some images and returns a flattened vector of one dimension.

155

Well this inverted CNN of the generator will do exactly the opposite it will take as input a vector

156

one dimension and we'll return the images or return some fake images and since we specify here that

157

the input vector is of size 100.

158

Well right now we are exactly going to create a vector of size 100.

159

This will be a random vector and that will represent some noise and then we'll feed the neural network

160

of the generator with this random vector and it will return some fake images.

161

Of course at the beginning it will return some images that look like nothing but over the books we will

162

update the weights so that the images look like something that is look like some real images.

163

But before doing that that's actually what we'll be doing.

164

The second step before doing that we need to train the discriminator to recognize what's fake.

165

So let's do this let's make this random vector of size 100.

166

And as we just said we're going to call it noise it actually represents some noise being a random input

167

vector.

168

So to create with by toward a vector of random values of a specific size Well it's actually very simple

169

We have a function for this.

170

This function we get it from the torch library of course and the name of this function is round and

171

runs.

172

And now inside this runs and function we need to input several arguments.

173

The first one is going to be the batch size which I remind is 64.

174

So that's the first argument we to input here.

175

And therefore I'm going to copy this batch size which I got for my one function.

176

There we go.

177

Copy and paste.

178

So we need to input this first argument of the batch size because we're not only going to create one

179

random vector of size 100 we're going to create of course a mini batch of random vectors of size 100.

180

So that then we can get a mini batch of fake images.

181

So input size corresponds to the size of the batch and then the second argument will be well the number

182

of elements we want in this vector and that is 100 because we specify in the architecture of the generator

183

that the input vector should be of size 100 and then we're going to add to arguments which are going

184

to be one and one and that is just to give to these random vectors some vague dimensions that will correspond

185

to a future map that is in fact instead of having 100 values in the vector.

186

It's like we will have 100 feature maps of size one by one meaning each of the 100 feature maps will

187

be a matrix of size one by one.

188

Great.

189

So now we get our noise.

190

So are we ready to move on to the next step.

191

Well no no we're not.

192

Because always for the same reason we have to wrap this mini batch of random vectors inside a variable.

193

Why is that.

194

That's because this noise here is going to be the input of the new one that work of the generator and

195

neural networks and pite which only accept torch variables.

196

So let's do that quickly.

197

Let's get our variable class and put this torche tensor of random vectors inside the variable so that

198

now noise becomes an object of this variable class containing this tensor.

199

Right.

200

And now we are allowed to move on to the next step.

201

So now according to you what is the next step.

202

Well obviously the next step is to get what we want.

203

That is this new ground truth.

204

We're looking for which of the fake images and the fake images we can now get them because we have the

205

right inputs of the neural network of the generator.

206

So let's get them we're going to call them fake.

207

But keep in mind that this will represent a mini batch of fake images a fake is the name of the match

208

so fake equals.

209

Then very simply again we're going to take the neural network of the generator to which we're going

210

to feed.

211

Well this noise mini batch containing the random vectors and therefore will get a mini batch of the

212

same size containing some fake images.

213

Awesome.

214

So now it is important to understand that this is the new input compared to this one.

215

This was the input containing the ground truth of the real images.

216

And this is a new input containing the ground truth of the fake images and therefore very quickly will

217

get the new output.

218

That is the output we'll get after feeding our discriminator with these new inputs fake images.

219

But before we get this outputs we need to get the target.

220

And now that's crucial to understand that this time the target is going to be a new kind of target.

221

And so what is it going to be.

222

Well this time since we are training the discriminator with some fake images we want to train it to

223

recognize the fake images we want to train it to recognize what's fake and therefore the target should

224

be the rejection of the images and the rejection of the images correspond to 0 0 means that the image

225

is rejected by the generator and therefore the target should be this time a sensor full of zeroes.

226

And so what I'm going to do I'm going to take this again because it's the same we're going to wrap it

227

into a viable but instead of using the ones function to get sensor full of ones.

228

Well I'm going to replace it by guess what zeros we have these very practical functions intuitive to

229

remember and by torche this time we have the zero's function that will return a sensor full of zeros

230

and the number of zeroes will be the size of the batch and put that size of index zero.

231

Perfect.

232

We have our new target.

233

And so now let's get the outputs.

234

So I'm going to introduce the variable for this output which I'm going to call outputs again and to

235

get my new output.

236

Well I'm going to take the neural network of the discriminator because we're still training discriminator

237

and I'm going to feed this do all that work with of course the fake images and then for each of the

238

fake images of the fake mini batch Well you'll get a prediction which is a discriminating number between

239

0 and 1.

240

And again if it is close to zero the discriminator will reject the image and if it is close to one it

241

will accept it.

242

All right perfect.

243

But we can do something actually better here.

244

We can save up some memory.

245

Remember that fake is a total variable because the output of a PI torche neural network is also a torch

246

variable and therefore it contains not only the tensor of the predictions the discriminating numbers

247

between 0 and 1 but also the gradients.

248

But actually we're not going to use this gradient after back propagating the error back inside the neural

249

network and when applying stochastic great in the sense.

250

So what we can do now is actually detach the gradient of this fake torche viable that will save up some

251

memory and that will speed up the computations.

252

And trust me we want to do this because the training is going to take quite a while.

253

So want to savor as much memory as possible and get the fastest computations as possible.

254

So we're going to detach the gradient here of this toward horrible and to do this we are done here and

255

then detach and then some parenthesis we absolutely don't care of the gradient of the output with respect

256

to the weight of the generator.

257

It will not be part of the considerations in stochastic gradient descent.

258

All right so now we have the time yet we have the output.

259

So guess what we're ready to have we are ready to have the new error corresponding to the training of

260

the discriminator with the fake images.

261

So let's do this.

262

And actually it's very simple we just need to copy this line because it's almost going to be the same.

263

We will just need to change the name of this new error.

264

So this new error corresponds to the training of the discriminator with the fake image.

265

So instead of calling it we are the real we will call it R R D fake.

266

And there we go and then that's the same because we have the same variable names for the outputs and

267

the target.

268

Wonderful.

269

And so now congratulations you are done with the two trainings that we had to do with the discriminator.

270

We trained the discriminator to recognize real images and fake images.

271

So two subsets done one more to go and we'll do the last one about back propagating the total error

272

back into the new one that work of discriminator and the next tutorial.

273

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.