MorvanZhou / PyTorch-Tutorial

Build your neural network easy and fast, 莫烦Python中文教学
https://mofanpy.com/tutorials/machine-learning/torch/
MIT License
8.14k stars 3.12k forks source link

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

Open wangchaozheng opened 5 years ago

wangchaozheng commented 5 years ago

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

MorvanZhou commented 5 years ago

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.

wangchaozheng commented 5 years ago

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