Merge pull request #25 from chenyuntc/master

set noisev to Volatile to freeze netG when updating netD.
This commit is contained in:
Soumith Chintala 2017-03-11 10:13:05 -05:00 committed by GitHub
commit 18a889b70e
1 changed files with 2 additions and 3 deletions

View File

@ -190,10 +190,9 @@ for epoch in range(opt.niter):
# train with fake # train with fake
noise.resize_(opt.batchSize, nz, 1, 1).normal_(0, 1) noise.resize_(opt.batchSize, nz, 1, 1).normal_(0, 1)
noisev = Variable(noise) noisev = Variable(noise, volatile = True) # totally freeze netG
fake = netG(noisev) fake = Variable(netG(noisev).data)
inputv = fake inputv = fake
inputv.detach()
errD_fake = netD(inputv) errD_fake = netD(inputv)
errD_fake.backward(mone) errD_fake.backward(mone)
errD = errD_real - errD_fake errD = errD_real - errD_fake