nv-tlabs / semanticGAN_code

Official repo for SemanticGAN https://nv-tlabs.github.io/semanticGAN/
MIT License
180 stars 34 forks source link

Is requires_grad(discriminator_img, False) infection dimg regulation #25

Open linyu0219 opened 2 years ago

linyu0219 commented 2 years ago

In train_seg_gan.py, when train dseg

requires_grad(generator, False)
requires_grad(discriminator_img, False)
requires_grad(discriminator_seg, True)

but in regulation part, dont open the toggle, dose this infection the dimg regularize?

if d_regularize:
    real_img.requires_grad = True
    real_pred = discriminator_img(real_img)
    r1_img_loss = d_r1_loss(real_pred, real_img)

    discriminator_img.zero_grad()
    (args.r1 / 2 * r1_img_loss * args.d_reg_every + 0 * real_pred[0]).backward()

    d_img_optim.step()
lidaiqing commented 2 years ago

hi @linyu0219 , thank you for your question. I think it makes sense to enable to gradient for both discriminators in the regularization, this might be a mistake when we refactor the codebase. Could you share some training results if you have?

linyu0219 commented 2 years ago

@lidaiqing I haven't started training yet