Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep Convolutional GAN Poor Result Quality #11

Open
gmcmacran opened this issue Jan 21, 2023 · 2 comments
Open

Deep Convolutional GAN Poor Result Quality #11

gmcmacran opened this issue Jan 21, 2023 · 2 comments

Comments

@gmcmacran
Copy link

First, I read you book and really enjoyed it. I liked how clearly you explained concepts and provided code within the text. I learned a lot.

Github code: The code on GitHub is https://github.com/PacktPublishing/Deep-Learning-with-TensorFlow-2-and-Keras/blob/master/Chapter%206/DCGAN.ipynb
Book: Deep Learning with TensorFlow 2 and Keras Second Edition

I am working on recreating the deep convolutional GAN starting on page 198 and finding the quality of results changes drastically run to run. I would like to rule out a few discrepancies between the book and the current GitHub code.

  1. On page 199, the book says the learning rate is 0.002. Two zeros after the decimal place. On GitHub and in book’s code, the learning rate 0.0002. Three zeros after the decimal place. Which one is correct?

  2. On page 200, the text says noise is 100 dimensions. In the book, the code is aligned to this. Z has a default value of 100 and is unchanged when the instance is created. On GitHub, the default is 10. Not 100. Is one value preferred over the other? Is this an insignificant choice?

  3. For the vanilla gan, the discriminator's weights are set to trainable before calling discriminator.train_on_batch. Then the weights are reverted back to not trainable when gan.train_on_batch is called. For the deep convolutional GAN, the discriminator’s weights are never set to trainable. Was this on purpose?

  4. For the vanilla gan, the discriminator receives one set of fake data. Then a different random sample is created and the GAN is trained. For the deep convolutional gan, the discriminator and gan are trained on the same random sample of noise. Is there a reason for the difference? Is this an insignificant choice?

@amita-kapoor
Copy link
Collaborator

Dear @gmcmacran,

Thank you for taking the time to read our book and for your feedback. I'm glad you found it helpful in your learning journey.

Regarding the questions you raised:

  1. The correct value for the learning rate is 0.0002. This value was updated in the GitHub code and is the current one being used.
  2. The default value for noise being 100 dimensions is preferred, but this is not a significant choice as you can experiment with different dimensions to see what works best for your use case.
  3. The change in the weights' trainability in the deep convolutional GAN was intentional and done to optimize the training process.
  4. The difference in the training process between the vanilla GAN and the deep convolutional GAN is also intentional. This approach was chosen better to balance the training of the generator and discriminator networks.

Regarding the discrepancies in result, I rechecked the code- there is a small error- the present code is training only for the batch size- instead of half images as mentioned in the comments. I have corrected it, and you can access the correct notebook- with name DCGAN_MNIST.ipynb.

I hope this helps answer your questions. If you have any more queries, feel free to reach out.

@gmcmacran
Copy link
Author

gmcmacran commented Feb 15, 2023

Thanks for responding. Follow up question to question 3 above.

In the deep convolutional GAN, are weights for the discriminator getting updated after calling train_on_batch? If yes, what does setting self.discriminator.trainable = False do inside the initialization function?

If no, what is the purpose of self.discriminator.train_on_batch() in the train function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants