mahmoudnafifi / HistoGAN

Reference code for the paper HistoGAN: Controlling Colors of GAN-Generated and Real Images via Color Histograms (CVPR 2021).
MIT License
267 stars 27 forks source link

Derivative bugs #4

Closed weepiess closed 3 years ago

weepiess commented 3 years ago

Hi,

for l in range(L):
      I = torch.t(torch.reshape(X[l], (3, -1)))
      II = torch.pow(I, 2)
      if self.intensity_scale:
        Iy = torch.unsqueeze(torch.sqrt(II[:, 0] + II[:, 1] + II[:, 2]), dim=1)
      else:
        Iy = 1

I found a bug here:

torch.sqrt(II[:, 0] + II[:, 1] + II[:, 2]), dim=1)

sqrt is not derivable at point 0 Therefore, it is better to change to this:

torch.sqrt(II[:, 0] + II[:, 1] + II[:, 2]+ EPS), dim=1)
mahmoudnafifi commented 3 years ago

Thanks for catching this. Fixed.