KernelGAN icon indicating copy to clipboard operation
KernelGAN copied to clipboard

Random noise added to real and simulated patch before passing Discriminator

Open a2bc opened this issue 8 months ago • 2 comments

Hi, Thanks so much for this paper and code. I track the code and see that: In kernelGAN.py d_pred_fake = self.D.forward((g_output + torch.randn_like(g_output) / 255.).detach())

In data.py

if not for_g:  # Add noise to the image for d
            crop_im += np.random.randn(*crop_im.shape) / 255.0

there is a Gaussian random noise with mean = 0 and std = 1/255 added to both the fake and real patches before passing to the Discriminator.

I read the paper and don't see any information about this trick. Can you give me some hints/motivations why you need this noise ? Thanks !

a2bc avatar May 28 '25 09:05 a2bc

of course - this is super important for GANs and images. Since real pixel values are integers, they can be ONLY very specific values between 0-1 (i.e. 1/255, 2/255, 3/255...) Therefore, a discriminator can distinguish between real and fake images easily by determining: if all pixels are n/255 exactly it is real, o.w. fake.

This is why you should add noise to "not allow" the discriminator have such an easy task

Is this clear?

sefibk avatar May 28 '25 09:05 sefibk

of course - this is super important for GANs and images. Since real pixel values are integers, they can be ONLY very specific values between 0-1 (i.e. 1/255, 2/255, 3/255...) Therefore, a discriminator can distinguish between real and fake images easily by determining: if all pixels are n/255 exactly it is real, o.w. fake.

This is why you should add noise to "not allow" the discriminator have such an easy task

Is this clear?

Totally make sense ;-) Thanks for the quick feedback !

a2bc avatar May 28 '25 09:05 a2bc