Code Monkey home page Code Monkey logo

Comments (4)

fchollet avatar fchollet commented on June 12, 2024

Yes, that's in scope and it seems straightforward.

I'm curious, what are you building that requires all these niche linalg ops?

from keras.

fchollet avatar fchollet commented on June 12, 2024

I've investigated this, and it's actually impossible to achieve consistency across backends for the resid and s return values (the solutions x, the first returned value, is fine). Even jax.numpy isn't consistent with numpy. Torch does it differently from both as well (despite having the same API).

We could make the function only return x. Are the other values ever useful?

Looking at code in the wild I could only find samples that used x. Other values area apparently always discarded. It's a pretty weird API tbh.

from keras.

jonbarron avatar jonbarron commented on June 12, 2024

yeah I think it makes sense to only return x, and I can imagine very few use-cases where the caller would really care about the other outputs. It might be helpful to return None for the other 3 outputs of the numpy interface just so it's a drop-in replacement for JAX. The other upside to having placeholder None outputs is that it avoids a potential footgun in case someone happens to be solving for an x with x.shape[0] == 4, as if they call lstsq with 4 output slots it will silently unstack the tensor along the first dimension which is definitely not what the caller would want.

from keras.

fchollet avatar fchollet commented on June 12, 2024

For reference, TensorFlow's tf.linalg.lstsq only returns x https://www.tensorflow.org/api_docs/python/tf/linalg/lstsq (though it also has a different signature).

I added the API, only returning x. Returning None entries would be problematic since ops are only ever supposed to return tensors.

from keras.

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.