Root decomposition fails for simple matrices
See original GitHub issueObserving the following:
I = torch.eye(4)
NonLazyTensor(I).root_decomposition()
# this will often return nans, and sometimes an approx. solution
tensor([[nan, nan, nan],
[nan, nan, nan],
[nan, nan, nan],
[nan, nan, nan]])
Inoise = I + 1e-3 * torch.diag(torch.rand(4))
NonLazyTensor(Inoise).root_decomposition()
tensor([[ 1.6966e-05, -1.0755e-05, 1.0002e+00, -1.2987e-04],
[-1.0000e+00, -1.4206e-03, 1.3592e-05, 5.5494e-06],
[ 1.4198e-03, -1.0000e+00, -1.9231e-06, -1.2009e-05],
[-5.9421e-06, 1.3196e-05, -1.0358e-04, -1.0005e+00]])
Ddiag = torch.ones(4)
DiagLazyTensor(Ddiag).root_decomposition()
# again most of the time this is nan and sometimes an approx solution
tensor([[nan, nan, nan],
[nan, nan, nan],
[nan, nan, nan],
[nan, nan, nan]])
Ddiagnoise = Ddiag + 1e-3 * torch.rand(4)
DiagLazyTensor(Ddiagnoise).root_decomposition()
tensor([[ 0.0002, 1.0002, 0.0010, -0.0000],
[ 0.9999, 0.0002, -0.0001, 0.0001],
[ 0.0002, 0.0002, -0.0004, -1.0006],
[-0.0003, -0.0010, 1.0003, -0.0000]])
At least for DiagLazyTensor
we should just short-circuit the special-case and just return DiagLazyTensor(torch.sqrt(input_diag))
. Not sure about the other cases, things seem to work reasonably if the matrices have off-diagonal elements.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
TDecompBase Class Reference - ROOT
If the matrix is flagged as being singular, operations with the decomposition will fail and will return matrices/vectors that are invalid .
Read more >Matrix decomposition - Wikipedia
In the mathematical discipline of linear algebra, a matrix decomposition or matrix factorization is a factorization of a matrix into a product of...
Read more >Linear Algebra and Matrix Decompositions - Duke People
This decomposition is known as the Cholesky decompostion, and L may be interpreted as the 'square root' of the matrix A. Algorithm:¶. Let...
Read more >the decompositional approach - Computer Science, FSU
The introduction of matrix decomposition into numerical linear algebra revolutionized ... Because triangular systems are easy to solve, the.
Read more >The Polar Decomposition and Principal Square Root of a ...
We introduce the principal square root of a positive semidefinite matrix, as well as the polar decomposition of a matrix (which generalizes ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually @gpleiss this is an issue that would also go away if we use pivoted Cholesky for root decompositions in place of Lanczos
This should be solved in #361 (at least the specific issue that I saw).