roatienza / Deep-Learning-Experiments

Videos, notes and experiments to understand deep learning
MIT License
1.1k stars 760 forks source link

Should the discriminator's parameter be frozen during training adversarial model? #5

Closed germunwang closed 6 years ago

germunwang commented 7 years ago

Hi, I have a question as the title when I was studying DCGAN.

I found some other DCGAN examples of keras and it seems they will set the discriminator's parameter non-trainable during training adversarial. Then resume it to trainable once training only discriminator model again.

But it seems in your DCGAN code doesn't do the work. (that means setting trainable=False and recompile the model) Is that a bug or did I misunderstand the training process of DCGAN?

Thanks.

roatienza commented 7 years ago

In DCGAN, both the discriminator and generator should learn together. I also see other approaches wherein the discriminator is pre-trained and re-trained together with the generator. This approach is not a good idea since we want both the discriminator and generator to have non-vanishing gradients. If the discriminator is ahead of the training, it could no longer propagate gradients down to the generator. Freezing the discriminator when training generator might also work.

germunwang commented 7 years ago

I got it. Thanks for replying. :)

RohithKuditipudi commented 6 years ago

To follow up on this, because you're labeling generated images as "1" when training the adversarial model, I think you have to freeze the discriminator. Otherwise, the discriminator will learn to assign "1" to both real and fake images.