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

Method forward

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

Source from the content-addressed store, hash-verified

125 return torch.tanh(alpha * generated + (1 - alpha) * upscaled)
126
127 def forward(self, x, alpha, steps):
128 out = self.initial(x)
129
130 if steps == 0:
131 return self.initial_rgb(out)
132
133 upscaled = 0
134
135 for step in range(steps):
136 #每一个convblock之后进行上采样
137 upscaled = F.interpolate(out, scale_factor=2, mode="nearest")
138 #进入下一个convblock
139 out = self.prog_blocks[step](upscaled)
140
141 """
142 # The number of channels in upscale will stay the same, while
143 # out which has moved through prog_blocks might change. To ensure
144 # we can convert both to rgb we use different rgb_layers
145 # (steps-1) and steps for upscaled, out respectively
146 """
147 final_upscaled = self.rgb_layers[steps - 1](upscaled)
148 final_out = self.rgb_layers[steps](out)
149 return self.fade_in(alpha, final_upscaled, final_out)
150
151"""
152判别器通道数从:[4 -> 8 ->] 16 -> 32 -> 64 -> 128 -> 256 -> 512 -> 512 -> 512 -> 512

Callers

nothing calls this directly

Calls 1

fade_inMethod · 0.95

Tested by

no test coverage detected