Skip to content

Instantly share code, notes, and snippets.

@harsh-99
Last active February 27, 2020 16:06
Show Gist options
  • Save harsh-99/802ae7af38c77743ecdb48d75ac3d037 to your computer and use it in GitHub Desktop.
Save harsh-99/802ae7af38c77743ecdb48d75ac3d037 to your computer and use it in GitHub Desktop.
#to train the generator
# Input to generator is a noise of size random_size
z = torch.randn(batch_size, random_size)
output_image = generator(z)
output_discriminator = discriminator(output_image)
#to train the generator the output of this should be compared with real_labels.
#so we compare the output by real label.
#criterion -> BCE Loss
g_loss = criterion(outputs, real_labels)
optimizer_g.zero_grad()
g_loss.backward()
optimizer_g.step()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment