Giter Site home page Giter Site logo

Comments (6)

DianeBouchacourt avatar DianeBouchacourt commented on May 26, 2024

With a bit more research, it comes from the call of optimizer.step() here

optimizer.step()

commenting it out works fine, but then how to do the optimization step of the model before training the discriminator?

from disentangling-vae.

YannDubs avatar YannDubs commented on May 26, 2024

Hi @DianeBouchacourt,

This seems to be an issue with pytorch > 1.4 (e.g. pytorch/pytorch#39141 (comment) )

I.e. I'm currently modifying the weights before finishing computing the gradients, which is not allowed from pytorch 1.5.

I see 2 possibilities:

  • downgrading to 1.4. Probably the quickest for now.
  • moving VAE optimization right before discriminator optimization. I believe this should work, but I have to test it.

from disentangling-vae.

YannDubs avatar YannDubs commented on May 26, 2024

It should work now with Pytorch 1.7 (I only tested factor_mnist). Let me know if it doesn't and thank you for pointing the issue.

from disentangling-vae.

DianeBouchacourt avatar DianeBouchacourt commented on May 26, 2024

All good it works now, but doesn't it change the optimization dynamics ? Since now model parameters are not updated via optimizer.step() before latent_sample2 = model.sample_latent(data2) is called

from disentangling-vae.

YannDubs avatar YannDubs commented on May 26, 2024

I believe that it does slightly change the dynamics (in that the discriminator now tries to discriminate sample from "the previous step" but that shouldn't make a big difference). I don't see how to bypass that "issue" without computing the first sample twice (once for each optimizer)... But if you have a better suggestion I'm happy to change that.

What is important is that the gradient computation is correct, and I think it is because we are detaching the second sample z_perm = _permute_dims(latent_sample2).detach() and so no gradients flow in the VAE when computing the gradients for the discriminator.

from disentangling-vae.

DianeBouchacourt avatar DianeBouchacourt commented on May 26, 2024

OK thanks for the quick reply !

from disentangling-vae.

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.