Skip to content

Feature request: Singular-value decomposition (SVD) #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nsthorat opened this issue Apr 5, 2018 · 11 comments
Open

Feature request: Singular-value decomposition (SVD) #110

nsthorat opened this issue Apr 5, 2018 · 11 comments

Comments

@nsthorat
Copy link
Contributor

nsthorat commented Apr 5, 2018

From @caisq on January 20, 2018 17:16

This can mimic tensorflow's otf.linalg.svd: https://www.tensorflow.org/api_docs/python/tf/svd

This is useful for, among other things, the generating of orthogonal initial weights for RNNs.

Copied from original issue: tensorflow/tfjs-core#571

easadler pushed a commit to easadler/tfjs that referenced this issue Apr 12, 2018
* Const and let are es6 not ts syntax

I was a little thrown by the original statement, as `const` and `let` are valid vanilla es6.
@kedevked
Copy link
Contributor

Hi,
I will work on it

@caisq
Copy link
Contributor

caisq commented Aug 23, 2018

Thanks, @kedevked Looking forward to your PR. Let us know if you need any help or guidance.

@kedevked
Copy link
Contributor

kedevked commented Aug 23, 2018

I am going to implement it using the qr method. The algorithm is described here. I wonder from which discrepancy can we consider the convergence to be reached for a singular value, meaning that if at the ith iteration we have the value j and at the (i+1)th iteration we have the value k, I want to stop the iteration when k-i < threshold. What should the threshold be ?
Also, @caisq , @nsthorat could you please review the solve PR, as I am going to use it to find the singular vector for each singular value ?

@nsthorat nsthorat added the type:feature New feature or request label Oct 24, 2018
@ken-okabe
Copy link

I have a question, for node.

For Python version, svd is already there;
https://www.tensorflow.org/api_docs/python/tf/linalg/svd
and I guess these Python apis are based on C binaries.

tfjs for node is also based on the same C binary, I've heard. So I think it should be trivial to implement all of the apis that are already implemented in Python version, for tfjs for node.

I understand all of the apis of tfjs on browser is pure js and it seems a long way development to cover basic apis.

So, here's my question.

Is there any development policies that apis for both browser and node are synchlonized? If so, even there are exsiting binaries to bind from node, we must wait every api for browser pure js implementation.

If I miss something, plese advice. Thanks.

nsthorat pushed a commit that referenced this issue Aug 19, 2019
This adds a `npm run coverage` script.

It does not introduce Travis + coveralls.io/codecov.io
integration yet, this is just the first step aimed at
getting coverage reports locally.

Has two reporters enabled: `text-summary` (to console) and
`html` (detailed output written to `./coverage/` dir).

`instrument` is required for coverage to work

`sourceMap` is required for proper source highlighting.

`cache` seems to be broken in ts-node setup, so it is
explicitly disabled.

All *.ts files from `src/` directory are analyzed,
excluding tests.
@lp74
Copy link

lp74 commented Sep 16, 2019

@kedevked, with a shift the convergence would be faster.

But I think that this problem is too way complex to be solved efficiently with a simple routine.

Tfjs needs to compute svd efficiently I guess.

Meanwhile, I use other libraries to compute svd and other useful stuffs, because I prefer to use efficiently the CPU than use the GPU in the wrong way.

See Lapack book: https://www.netlib.org/lapack/lug/node53.html

@kedevked
Copy link
Contributor

@nsthorat @caisq can you please tell us if it is still in the roadmap of tfjs to implement linear algebra operators ? If so, maybe you can give some pointers in the direction to go. Thanks !

@EddieOne
Copy link
Contributor

It would be nice to have a way to test SVD in TFJS.

@kedevked
Copy link
Contributor

@EddieOne Yes indeed, that would be nice to have. But I guess the tfjs team for now have decided not to include this operators in the core library.

@EddieOne
Copy link
Contributor

As I understand it, we need more floating points in JS to get the accuracy needed for SVD. But I am fuzzy on the details. I was going to try more interpolation without SVD and see what happens.

@rthadur rthadur added the P3 label Sep 1, 2021
@tsol
Copy link

tsol commented Feb 18, 2023

Not a single one implementation of SVD i found in NPM decomposes [8,9] matrix exactly like pyhons Numpy.lialg.svd function. I really hoped tfjs would have one...

@gaikwadrahul8
Copy link
Contributor

Hi, @nsthorat

Thank you for opening this issue for tracking purposes. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.

The TFJs team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TFJs version with the latest compatible hardware configuration which could potentially resolve the issue. We can keep the issue open if it is still relevant. Please confirm if we need to keep the issue open.

Thank you for your support and cooperation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants