PyTorch-Tutorial icon indicating copy to clipboard operation
PyTorch-Tutorial copied to clipboard

Question about GAN code: update the generator while training the discriminator

Open wangchaozheng opened this issue 6 years ago • 2 comments

Through reading ur code, I think you update the generator while training the discriminator. We should detach it while training the discriminator, right?

wangchaozheng avatar Aug 01 '19 18:08 wangchaozheng

https://github.com/MorvanZhou/PyTorch-Tutorial/blob/master/tutorial-contents/406_GAN.py#L52-L53

opt_D = torch.optim.Adam(D.parameters(), lr=LR_D)
opt_G = torch.optim.Adam(G.parameters(), lr=LR_G)

This will update G and D separately.

MorvanZhou avatar Aug 02 '19 01:08 MorvanZhou

Thanks man, I understand now. I got confused by comparing ur code with the DCGAN tutorial on pytorch website. Thanks again!

wangchaozheng avatar Aug 02 '19 22:08 wangchaozheng