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

Output of the discriminator is not 1-D #17

Closed
JannisBush opened this issue Feb 21, 2019 · 2 comments
Closed

Output of the discriminator is not 1-D #17

JannisBush opened this issue Feb 21, 2019 · 2 comments

Comments

@JannisBush
Copy link

Hey,

In the README it is written that the last layer of the discriminator maps the output to a scalar.
So the output shape of the discriminator should be (?,1,1,1) or (?,1), but in fact it is (?,4,4,1).

Is this intended?

To see this, add self.dis_real = dis_real in line 199 and print(self.sess.run(self.dis_real, feed_dict=feed_dic).shape) in line 55 of models.py.
An easy fix for this problem, would be to use the padding="VALID" for the last layer of the discriminator.

Best regards,
Jannis

@knazeri
Copy link
Member

knazeri commented Feb 21, 2019

@JannisBush This was intended! We have to update the readme!
This class of discriminators is known as PatchGAN. The output of the discriminator is a 4x4 matrix with each index corresponding an image patch in the input. The receptive field of the network is 70x70 which means our discriminator evaluates 70x70 overlapping patches of the input image!

Philip Isola has a good explanation for this: junyanz/pytorch-CycleGAN-and-pix2pix#39 (comment)

This is all mathematically equivalent to if we had manually chopped up the image into 70x70 overlapping patches, run a regular discriminator over each patch, and averaged the results.

@JannisBush
Copy link
Author

@knazeri Thanks for your clarification.

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

No branches or pull requests

2 participants