Closed cl886699 closed 3 years ago
hey its a nice work , here i have a quesion in your essays the total loss added frcnn loss , but in this code ,i did not see
` if step % self.D_update_ratio == 0 and step > self.D_init_iters: if self.cri_pix: #pixel loss l_g_pix = self.l_pix_w self.cri_pix(self.fake_H, self.var_H) l_g_total += l_g_pix if self.cri_fea: # feature loss real_fea = self.netF(self.var_H).detach() #don't want to backpropagate this, need proper explanation fake_fea = self.netF(self.fake_H) #In netF normalize=False, check it l_g_fea = self.l_fea_w self.cri_fea(fake_fea, real_fea) l_g_total += l_g_fea
pred_g_fake = self.netD(self.fake_H) if self.configT['gan_type'] == 'gan': l_g_gan = self.l_gan_w * self.cri_gan(pred_g_fake, True) elif self.configT['gan_type'] == 'ragan': pred_d_real = self.netD(self.var_ref).detach() l_g_gan = self.l_gan_w * ( self.cri_gan(pred_d_real - torch.mean(pred_g_fake), False) + self.cri_gan(pred_g_fake - torch.mean(pred_d_real), True)) / 2 l_g_total += l_g_gan #EESN calculate loss self.lap_HR = kornia.laplacian(self.var_H, 3) if self.cri_charbonnier: # charbonnier pixel loss HR and SR l_e_charbonnier = 5 * (self.cri_charbonnier(self.final_SR, self.var_H) + self.cri_charbonnier(self.x_learned_lap_fake, self.lap_HR))#change the weight to empirically l_g_total += l_e_charbonnier #### did not see the frcnn loss l_g_total.backward(retain_graph=True) self.optimizer_G.step()
`
Faster RCNN loss was backpropagated separately like GAN loss, check the later lines. Therefore, the total loss is shown by addition.
hey its a nice work , here i have a quesion in your essays the total loss added frcnn loss , but in this code ,i did not see
` if step % self.D_update_ratio == 0 and step > self.D_init_iters: if self.cri_pix: #pixel loss l_g_pix = self.l_pix_w self.cri_pix(self.fake_H, self.var_H) l_g_total += l_g_pix if self.cri_fea: # feature loss real_fea = self.netF(self.var_H).detach() #don't want to backpropagate this, need proper explanation fake_fea = self.netF(self.fake_H) #In netF normalize=False, check it l_g_fea = self.l_fea_w self.cri_fea(fake_fea, real_fea) l_g_total += l_g_fea
`