MCPcopy Create free account
hub / github.com/JunlinHan/DCLGAN / data_dependent_initialize

Method data_dependent_initialize

models/fastcut_model.py:88–105  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

set_inputMethod · 0.95
forwardMethod · 0.95
compute_D_lossMethod · 0.95
compute_G_lossMethod · 0.95
backwardMethod · 0.80

Tested by

no test coverage detected