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

Method data_dependent_initialize

models/dcl_model.py:110–127  ·  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

108 self.optimizers.append(self.optimizer_D)
109
110 def data_dependent_initialize(self, data):
111 """
112 The feature network netF is defined in terms of the shape of the intermediate, extracted
113 features of the encoder portion of netG. Because of this, the weights of netF are
114 initialized at the first feedforward pass with some input images.
115 Please also see PatchSampleF.create_mlp(), which is called at the first forward() call.
116 """
117 self.set_input(data)
118 bs_per_gpu = self.real_A.size(0) // max(len(self.opt.gpu_ids), 1)
119 self.real_A = self.real_A[:bs_per_gpu]
120 self.real_B = self.real_B[:bs_per_gpu]
121 self.forward() # compute fake images: G(A)
122 if self.opt.isTrain:
123 self.compute_G_loss().backward() # calculate graidents for G
124 self.backward_D_A() # calculate gradients for D_A
125 self.backward_D_B() # calculate graidents for D_B
126 self.optimizer_F = torch.optim.Adam(itertools.chain(self.netF1.parameters(), self.netF2.parameters()))
127 self.optimizers.append(self.optimizer_F)
128
129 def optimize_parameters(self):
130 # forward

Callers 2

train.pyFile · 0.45
test.pyFile · 0.45

Calls 6

set_inputMethod · 0.95
forwardMethod · 0.95
compute_G_lossMethod · 0.95
backward_D_AMethod · 0.95
backward_D_BMethod · 0.95
backwardMethod · 0.80

Tested by

no test coverage detected