Merge pull request #8 from FeepingCreature/fix-generator-train-size

Make sure the generator training always gets a full batch of noise
This commit is contained in:
martinarjovsky 2017-02-06 13:56:28 -05:00 committed by GitHub
commit a6c76da533
1 changed files with 3 additions and 0 deletions

View File

@ -203,6 +203,9 @@ for epoch in range(opt.niter):
for p in netD.parameters(): for p in netD.parameters():
p.requires_grad = False # to avoid computation p.requires_grad = False # to avoid computation
netG.zero_grad() netG.zero_grad()
# in case our last batch was the tail batch of the dataloader,
# make sure we feed a full batch of noise
noise.data.resize_(opt.batchSize, nz, 1, 1)
noise.data.normal_(0, 1) noise.data.normal_(0, 1)
fake = netG(noise) fake = netG(noise)
errG = netD(fake) errG = netD(fake)