Skip to content

Instantly share code, notes, and snippets.

@harsh-99
Last active February 27, 2020 16:11
Show Gist options
  • Save harsh-99/c0e9fdeaa320c9e4a52f58c4d74a2cee to your computer and use it in GitHub Desktop.
Save harsh-99/c0e9fdeaa320c9e4a52f58c4d74a2cee to your computer and use it in GitHub Desktop.
#To train the Discriminator
output_d_real = discriminator(real_images)
d_real_loss = criterion(output_d_real, real_labels)
z = torch.randn(batch_size, random_size).to(device)
fake_images = generator(z)
output_d_fake = discriminator(fake_images)
d_fake_loss = criterion(output_d_fake, fake_labels)
d_loss = d_real_loss + d_fake_loss
optimizer_d.zero_grad()
d_loss.backward()
optimizer_d.step()#this is going to update only parameters of discriminator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment