Merge pull request #25 from chenyuntc/master
set noisev to Volatile to freeze netG when updating netD.
This commit is contained in:
commit
18a889b70e
5
main.py
5
main.py
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue