MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / forward

Method forward

ProGAN/model.py:207–238  ·  view source on GitHub ↗
(self, x, alpha, steps)

Source from the content-addressed store, hash-verified

205 return torch.cat([x, batch_statistics], dim=1)
206
207 def forward(self, x, alpha, steps):
208 # where we should start in the list of prog_blocks, maybe a bit confusing but
209 # the last is for the 4x4. So example let's say steps=1, then we should start
210 # at the second to last because input_size will be 8x8. If steps==0 we just
211 # use the final block
212 cur_step = len(self.prog_blocks) - steps
213
214 # convert from rgb as initial step, this will depend on
215 # the image size (each will have it's on rgb layer)
216 out = self.leaky(self.rgb_layers[cur_step](x))
217
218 if steps == 0: # i.e, image is 4x4
219 out = self.minibatch_std(out)
220 return self.final_block(out).view(out.shape[0], -1)
221
222 # because prog_blocks might change the channels, for down scale we use rgb_layer
223 # from previous/smaller size which in our case correlates to +1 in the indexing
224 #先下采样之后经过rgb_layers层
225 downscaled = self.leaky(self.rgb_layers[cur_step + 1](self.avg_pool(x)))
226 #经过convblock之后直接下采样
227 out = self.avg_pool(self.prog_blocks[cur_step](out))
228
229 # the fade_in is done first between the downscaled and the input
230 # this is opposite from the generator
231 out = self.fade_in(alpha, downscaled, out)
232
233 for step in range(cur_step + 1, len(self.prog_blocks)):
234 out = self.prog_blocks[step](out)
235 out = self.avg_pool(out)
236
237 out = self.minibatch_std(out)
238 return self.final_block(out).view(out.shape[0], -1)
239
240
241if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

minibatch_stdMethod · 0.95
fade_inMethod · 0.95

Tested by

no test coverage detected