Skip to content

Commit

Permalink
setting opt.identity other than 1 has an effect of scaling the weight…
Browse files Browse the repository at this point in the history
… of the identity mapping loss. For example, if the weight of the identity loss should be 10 times smaller than the weight of the reconstruction loss, please set opt.identity = 0.1
  • Loading branch information
Taesung Park committed Apr 3, 2017
1 parent f7801e1 commit 3fb35c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions models/cycle_gan_model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ function CycleGANModel:fGx_basic(x, gradParams, netG, netD, netE, real, real2, r
-- G should be identity if real2 is fed.
local errI = nil
local identity = nil
if opt.identity == 1 then
if opt.identity > 0 then
identity = netG:forward(real2):clone()
errI = self.criterionRec:forward(identity, real2)*lambda2
local didentity_loss_do = self.criterionRec:backward(identity, real2):mul(lambda2)
errI = self.criterionRec:forward(identity, real2)*lambda2*opt.identity
local didentity_loss_do = self.criterionRec:backward(identity, real2):mul(lambda2):mul(opt.identity)
netG:backward(real2, didentity_loss_do)
end

Expand Down

0 comments on commit 3fb35c1

Please sign in to comment.