Giter Site home page Giter Site logo

Comments (4)

vanhuyz avatar vanhuyz commented on May 25, 2024

Actually, there are 2 generators G and F which are trained separately. Each generator loss is a sum of GAN loss and cycle loss.

from cyclegan-tensorflow.

theflashsean1 avatar theflashsean1 commented on May 25, 2024

Yes, but isn't cycle loss for G (which takes x as input, and produces G(x) as output) "forward_loss = tf.reduce_mean(tf.abs(F(G(x))-x))"

And cycle loss for F "tf.reduce_mean(tf.abs(G(F(y))-y))"

When you defined "cycle_loss = self.cycle_consistency_loss(self.G, self.F, x, y)" on line 72, I thought you've already written this loss as sum of two cycle losses for each generator

from cyclegan-tensorflow.

vanhuyz avatar vanhuyz commented on May 25, 2024

The original paper and PyTorch implementation optimize F and G simultaneously, so there is only 1 objective function for 2 generators:

L(G, F) = L_gan(G) + L_gan(F) + L_cycle

# optimize
AdamOptimizer(L(G, F))

But my implementation is based on the Torch implementation. If I understand correctly, loss of G and loss of F are computed separately as follows:

# compute losses
L_forward: x → G(x) → F(G(x)) ≈ x
L_backward: y → F(y) → G(F(y)) ≈ y
L_cycle = L_forward +  L_backward

L(G) = L_gan(G) + L_cycle
L(F) = L_gan(F) + L_cycle

# optimize separately
AdamOptimizer(L(G))
AdamOptimizer(L(F))

from cyclegan-tensorflow.

theflashsean1 avatar theflashsean1 commented on May 25, 2024

I see what you mean now. Both cycles need to be taken into account for each generator

from cyclegan-tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.