-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
acgan: Use Generator/Discriminator more closely resembling the ones from the referenced paper, and don't train discriminator to produce class labels for generated images #8482
Conversation
@lukedeo if your time allows, could you check out this PR as well? |
This extra "embedding" was removed: Actual and its Hadamard product (which is cool) are untouched: Please note that this PR is on top of PR #8452 |
Ah ok I see, sure, that extra hidden rep is extraneous and makes it more in-line with the paper. Re: #8452, how noticeable is the improvement in quality when the discriminator receives zero weight for the auxiliary task on generated samples? If we're going to go full paper reproduction mode, my thought is to go all the way. I could be fairly easily convinced though, as having the discriminator minimize classification accuracy on generated samples can lead to the generator not examining sections of the support where the the likelihood ratio approaches a flat posterior |
A brief history: Recently acgan example was broken - generating all-black images. The minimal first fix for it was to introduce soft real/fake labels, PR "acgan: Fix generator producing pure black images" #8383, see generated examples there. This fix was either mandatory for later fixes (to prevent all-black), or was producing batter results. So far, all further fixes made soft labels harder and harder, which is an evidence that those are good fixes). Second fix was PR "acgan: don't train discriminator to produce class labels for generated images" #8452, see generated examples there for how much more diverse they are than before. See #8452 (comment) for alternatives, and #8452 (comment) for the history how it ended up in the paper and the justification of its removal from the example (initially I was also hesitant to remove it, see the second sentence here: #8452 (comment)). It's better to keep the discussion of that PR in that PR. Third fix is this PR. It depends on second and first. |
Use same latent vector for all classes in a row
don't train discriminator to produce class labels for generated images
The following PRs were merged into this PR: acgan: Use same latent vector for all classes in a row #8409 See #8409 (comment) |
examples/mnist_acgan.py
Outdated
@@ -185,6 +182,13 @@ def build_discriminator(): | |||
num_batches = int(x_train.shape[0] / batch_size) | |||
progress_bar = Progbar(target=num_batches) | |||
|
|||
# don't train discriminator to produce class labels for generated | |||
# images. To preserve total weight of the auxilary classifier, | |||
# take real image samples with weight 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning of this comment is not clear, please rephrase/clarify
examples/mnist_acgan.py
Outdated
# don't train discriminator to produce class labels for generated | ||
# images. To preserve total weight of the auxilary classifier, | ||
# take real image samples with weight 2. | ||
disc_sample_weight = [np.ones(2 * batch_size, dtype=np.float32), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses float32
for one but not the other; it's not really necessary for either (memory is not an issue and they get cast anyway). In any case, better to be consistent
Review comments addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
This depends on PR #8452, and should be merged after it.
Generator:
Discriminator:
These changes