0

I implemented a GAN model and I would like the discriminator (UNET Discriminator) to compute decision over all pixels and [D(x)]i,j refer to the discriminator decision at pixel (i; j). The original loss in the paper is based on a vanilla Loss, but I would like to use a WGAN-GP loss in my case. How can I implement the below equation in pytorch

enter image description here

  • it's a bit unclear, implement for/as what. what is your goal? – Guy Nachshon Jan 16 '22 at 16:49
  • It is `D(x).sum()` for an appropriate definition of `D`. – erip Jan 16 '22 at 16:59
  • @GuyNachshon, I implemented a GAN model and I would like the discriminator (UNET Discriminator) to compute decision over all pixels and [D(x)]i,j refer to the discriminator decision at pixel (i; j). The original loss in the paper is based on a vanilla Loss, but I would like to use a WGAN-GP loss in myy case. – Najeh NAFTI Jan 16 '22 at 17:13
  • @erip what about the (i,j)? – Najeh NAFTI Jan 16 '22 at 17:14
  • If `D(x)` is a matrix, `D(x).sum()` is the same as `D(x).sum(axis=1).sum(axis=0)` which covers `i` (rows) and `j` (columns). – erip Jan 16 '22 at 17:14
  • @erip D(x) is a tensor of scores, where D is the discriminator model and x is the input image! – Najeh NAFTI Jan 16 '22 at 17:31
  • A model is a function from `R^m` to `R^n` so `D(x)` is in `R^n`. You need to sum over all dims which aren't the batch dim which is what your image is showing. For more help you'll need to add code. – erip Jan 16 '22 at 17:38
  • @erip I added more details above! – Najeh NAFTI Jan 16 '22 at 17:46
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 25 '22 at 16:38

0 Answers0