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 size discriminator #49

Closed
noob16 opened this issue Feb 10, 2017 · 10 comments
Closed

Output size discriminator #49

noob16 opened this issue Feb 10, 2017 · 10 comments

Comments

@noob16
Copy link

noob16 commented Feb 10, 2017

Hi,

why are you using an output size of 1x30x30 for the discriminator? and not just 1x1x1?

Thanks!

@phillipi
Copy link
Owner

This is because the (default) discriminator is a "PatchGAN" (Section 2.2.2 in the paper). This discriminator slides across the generated image, convolutionally, trying to classify if each overlapping 70x70 patch is real or fake. This results in a 30x30 grid of classifier outputs, each corresponding to a different patch in the generated image.

@kenshinzh
Copy link

@phillipi If I want to classify each overlapping a minor patch eg. like 16 x 16 patch is real or fake, should this results in a which size grid of classifier outputs? any formula or hints can provide?

@phillipi
Copy link
Owner

You can use this script to determine the receptive field (e.g., 16 x 16) of a given architecture:
https://github.com/phillipi/pix2pix/blob/master/scripts/receptive_field_sizes.m

I'm not sure what the formula would be for calculating output grid size given desired receptive field. For a given architecture, you can always check the output size by running it on an image and calling out:size() on the output out.

@kenshinzh
Copy link

@phillipi Thank you for you quick response. I am not familiar with the Matlab. Would you please be more specify how can I get the output with the script you provided. Thank you so much.

@phillipi
Copy link
Owner

phillipi commented Jun 24, 2017

That script gives you the receptive field of a neuron. The equation to compute the input receptive field size from a given output receptive field size is (for a single convolutional layer):
input_size = (output_size - 1) * stride + kernel_size

You can call this recursively to compute the receptive field sizes across multiple layers.

@kenshinzh
Copy link

kenshinzh commented Jun 25, 2017

@phillipi Thank you for you kind explanation. I am sorry that I didn't define my question well. The problem is when I use 70*70 patch GAN as discriminator in code, the output is not as sharp as what described in the paper in some occasion.
screen shot 2017-06-25 at 1 37 23 pm
This looks good, but my results is not sharp enough as sample

So I wonder maybe the patch GAN size as default code is 70*70 is too large for the discriminator to classify the fake or real. If I want to enhance the sharpness should I enlarge the patch size or decrease the patch size? or any other suggestions ?

@junyanz
Copy link
Collaborator

junyanz commented Jun 25, 2017

@kenshinzh what's your input and output? To produce good colorization results, one needs to map L to ab. Look at Notes on Colorization for more details.

@kenshinzh
Copy link

Actually, my experments is from a B2A direction which is not the color corrections. I just take this B/W for illustration. all the input image is as the demo 256*256

@phillipi
Copy link
Owner

In the colorizations in the paper, we concatenate the predicted ab map with the ground truth L. This has the effect of making the results look nice and crisp since most of the high frequencies are in the L channel. If you just look at the raw predicted ab it tends to look less sharp.

I don't think there is a simple relationship between discriminator patch size and and sharpness. In practice 70x70 usually works pretty well for me, but you could try a few variants to see what works in your application.

@phillipi
Copy link
Owner

phillipi commented Dec 25, 2017 via email

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

4 participants