24387ddc838a9eb4273c03bf19e3f35587e3f201,implementations/wgan/wgan.py,,,#,88
Before Change
for i in range(len(data_iter) // opt.n_critic):
// Train discriminator for n_critic times
for _ in range(opt.n_critic):
(imgs, _) = data_iter.next()
// Configure input
real_imgs = Variable(imgs.type(Tensor))
After Change
p.data.clamp_(-opt.clip_value, opt.clip_value)
// Train the generator every n_critic iterations
if i % opt.n_critic == 0:
// -----------------
// Train Generator
// -----------------
optimizer_G.zero_grad()
// Generate a batch of images
gen_imgs = generator(z)
// Adversarial loss
loss_G = -torch.mean(discriminator(gen_imgs))
loss_G.backward()
optimizer_G.step()
print ("[Epoch %d/%d] [Batch %d/%d] [D loss: %f] [G loss: %f]" % (epoch, opt.n_epochs,
batches_done % len(dataloader), len(dataloader),
loss_D.item(), loss_G.item()))
if batches_done % opt.sample_interval == 0:
save_image(gen_imgs.data[:25], "images/%d.png" % batches_done, nrow=5, normalize=True)
batches_done += 1
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: eriklindernoren/PyTorch-GAN
Commit Name: 24387ddc838a9eb4273c03bf19e3f35587e3f201
Time: 2018-05-07
Author: eriklindernoren@live.se
File Name: implementations/wgan/wgan.py
Class Name:
Method Name:
Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 5c362b15bdd7a158332d5ddc92b692416a10c834
Time: 2020-08-26
Author: 35782177+melaniedejong@users.noreply.github.com
File Name: iam/api-client/quickstartv2.py
Class Name:
Method Name: modify_policy_add_role
Project Name: ntucllab/libact
Commit Name: 325fae8fbbc16b3c1ca40559bb2a9c783efaf440
Time: 2015-11-25
Author: yangarbiter@gmail.com
File Name: libact/query_strategies/active_learning_by_learning.py
Class Name: ActiveLearningByLearning
Method Name: make_query