original_docstring: Calculate GAN loss for the discriminator
docstring: Calculate GAN loss for the discriminator
docstring_tokens: Calculate GAN loss for the discriminator
code: def backward_D(self):
          """Calculate GAN loss for the discriminator"""
          # Fake; stop backprop to the generator by detaching fake_B
          # we use conditional GANs; we need to feed both input and output to the discriminator
          fake_AB = torch.cat((self.real_A, self.fake_B), 1)
          pred_fake = self.netD(self.netF(self.real_A.detach()), self.netF(self.fake_B.detach()))  # D(G(F(fake)))
          self.loss_D_fake = self.criterionGAN(pred_fake, False)
          # Real
          real_AB = torch.cat((self.real_A, self.real_B), 1)
          pred_real = self.netD(self.netF(self.real_A), self.netF(self.real_B))           # D(G(F(real)))
          self.loss_D_real = self.criterionGAN(pred_real, True)
          # combine loss and calculate gradients
          self.loss_D = (self.loss_D_fake + self.loss_D_real) * 0.5
          self.loss_D.backward()
code_tokens: def backward_D ( self ) : fake_AB = torch . cat ( ( self . real_A , self . fake_B ) , 1 ) pred_fake = self . netD ( self . netF ( self . real_A . detach ( ) ) , self . netF ( self . fake_B . detach ( ) ) ) self . loss_D_fake = self . criterionGAN ( pred_fake , False ) real_AB = torch . cat ( ( self . real_A , self . real_B ) , 1 ) pred_real = self . netD ( self . netF ( self . real_A ) , self . netF ( self . real_B ) ) self . loss_D_real = self . criterionGAN ( pred_real , True ) self . loss_D = ( self . loss_D_fake + self . loss_D_real ) * 0.5 self . loss_D . backward ( )
short_docstring: Calculate GAN loss for the discriminator
short_docstring_tokens: Calculate GAN loss for the discriminator
comment: """Calculate GAN loss for the discriminator"""$SEP$# Fake; stop backprop to the generator by detaching fake_B
  $SEP$# we use conditional GANs; we need to feed both input and output to the discriminator
  $SEP$# D(G(F(fake)))
  $SEP$# Real
  $SEP$# D(G(F(real)))
  $SEP$# combine loss and calculate gradients
  