The feature network netF is defined in terms of the shape of the intermediate, extracted features of the encoder portion of netG. Because of this, the weights of netF are initialized at the first feedforward pass with some input images. Please also see PatchSampleF.c
(self, data)
| 86 | self.optimizers.append(self.optimizer_D) |
| 87 | |
| 88 | def data_dependent_initialize(self, data): |
| 89 | """ |
| 90 | The feature network netF is defined in terms of the shape of the intermediate, extracted |
| 91 | features of the encoder portion of netG. Because of this, the weights of netF are |
| 92 | initialized at the first feedforward pass with some input images. |
| 93 | Please also see PatchSampleF.create_mlp(), which is called at the first forward() call. |
| 94 | """ |
| 95 | self.set_input(data) |
| 96 | bs_per_gpu = self.real_A.size(0) // max(len(self.opt.gpu_ids), 1) |
| 97 | self.real_A = self.real_A[:bs_per_gpu] |
| 98 | self.real_B = self.real_B[:bs_per_gpu] |
| 99 | self.forward() # compute fake images: G(A) |
| 100 | if self.opt.isTrain: |
| 101 | self.compute_D_loss().backward() # calculate gradients for D |
| 102 | self.compute_G_loss().backward() # calculate graidents for G |
| 103 | if self.opt.lambda_NCE > 0.0: |
| 104 | self.optimizer_F = torch.optim.Adam(self.netF.parameters(), lr=self.opt.lr, betas=(self.opt.beta1, self.opt.beta2)) |
| 105 | self.optimizers.append(self.optimizer_F) |
| 106 | |
| 107 | def optimize_parameters(self): |
| 108 | # forward |
nothing calls this directly
no test coverage detected