Git Product home page Git Product logo

Comments (5)

mattjj avatar mattjj commented on September 1, 2024

It's probably a side-effect (in your code or objax) stashing a JAX tracer. I requested access to the notebook!

from objax.

bilal2vec avatar bilal2vec commented on September 1, 2024

sorry about that, I should've checked to see if the link worked. https://colab.research.google.com/drive/1gG0naJz_JbFHQwNxL9jTKeifwzVne6KE?usp=sharing

from objax.

mattjj avatar mattjj commented on September 1, 2024

I got a different error when running the cells:

image

Could you double check that it's a repro of the bug you care about? Btw, minimizing it would increase our chance of making progress :)

from objax.

david-berthelot avatar david-berthelot commented on September 1, 2024

This is the right place where to ask. I've got the same error as @mattjj when trying to reproduce it.
Your code you use both objax.functional.loss.cross_entropy_logits and objax.functional.loss.cross_entropy_logits_sparse. In both cases, the way the API is called is the cause.

In short, the nicest way to do it would be for g_loss is:

return objax.functional.loss.cross_entropy_logits_sparse(discriminator(fake_img, training=False), 1).mean()

And for d_loss, you could change the code accordingly (just use an int for the label).

Generally speaking, you could still use a tensor if you really wanted to, just make sure it has proper dimensionality, like this:

return objax.functional.loss.cross_entropy_logits(discriminator(fake_img, training=False), jnp.ones(x.shape[0])).mean()

More generally, one way I found to debug is to add print statement in various place to make sure my variables are okay, and you can find the places to look closely at the stack trace:

  File "dev/dcgan.py", line 137, in g_loss
    return objax.functional.loss.cross_entropy_logits(discriminator(fake_img, training=False), jnp.ones_like(x)).mean()

Hope it helps!

from objax.

bilal2vec avatar bilal2vec commented on September 1, 2024

Thank you! the code runs now!

from objax.

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.