pix2pixHD icon indicating copy to clipboard operation
pix2pixHD copied to clipboard

Feature Match loss Issue

Open wftang2020 opened this issue 4 years ago • 2 comments

hi tcwang:

  •  if not self.opt.no_ganFeat_loss:
    
  •         feat_weights = 4.0 / (self.opt.n_layers_D + 1)
    
  •         D_weights = 1.0 / self.opt.num_D
    
  •         for i in range(self.opt.num_D):
    
  •             for j in range(len(pred_fake[i])-1):
    
  •                 loss_G_GAN_Feat += D_weights * feat_weights * \
    
  •                     self.criterionFeat(pred_fake[i][j], pred_real[i][j].detach()) * self.opt.lambda_feat
    
    the paper mentioned that Dk only serves as a feature extractor and does not maximize the feature matching loss. but when I read the code, I see the last line only pred_real[i][j] using detach. Is it correct? Does "not maximize the loss" here mean the D not participate in autograd. so. you should set requires_grad of parameter of D as false

wftang2020 avatar Jan 07 '21 03:01 wftang2020

Have you solved the problem? I have the same question

Claire210222 avatar May 23 '21 14:05 Claire210222

You need to detach the target image logits, you only backpropagate the fake's. The code is correct.

victorca25 avatar Oct 31 '21 12:10 victorca25