-
Notifications
You must be signed in to change notification settings - Fork 52
[Consistency] Default behaviour of SVD vs QR #214
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
Comments
Thanks for the proposal @lezcano. It sounds sensible, it would be good to get some confirmation that this is the right thing to do. One way to go about that would be to check some of the |
That makes sense. I'll show a few examples here going in the order as they appear when you look for
Summary: These first examples show that in all the cases using |
Thanks @lezcano! That's convincing to me, +1 for changing the default. And I guess it's time to open a SciPy PR:) |
This is not accurate as in the mistake is that the 'reduced' part is about In scipy.linalg.qr and |
I agree, when I've used svd I cannot think of a case where I did not set |
@ilayn Can you elaborate a bit more on "most of the use cases require full output"? Which use cases do you have in mind? |
Like I mentioned almost all. From signal processing to control theory, identification, more esoteric matrix decompositions we always use full matrices. Other than low rank approximations and least squares problems I don't encounter economy mode of svds since often thin svd is comparable to QR to change the basis. Compact SVD is also a low-rank approximation but you can also use iterative methods with better performance for sizes of matrices that would make any difference. For reduced QR that's a mixed bag since depending on the matrix shape you can get both as useful as possible however that doesn't grant a ticket for changing the default to thin qr. Julia stopped the economy mode in 0.7ish for defaults I think, matlab also doesn't do thin or reduced by default for SVD or QR. So is the case for Mathematica for SVD but returns thin for QR but I haven't checked since years. Thus the only two I know of that doesn't fit the rest is numpy qr and mathematica qr which are strange. I wasn't around then so I don't know why it is selected. |
I agree with @shoyer. I have never had the need to use In the codebase of SciPy, I just found one use of In the field that I know best, that of matrix analysis and geometry, thin SVD and reduced QR are often used to simplify certain computations to smaller matrices. For example, when you compute the geodesics on the manifold of matrices with orthonormal columns (the Stiefel manifold) In a similar way, a reduced SVD may be used to compute the polar decomposition of a matrix. More generally, it allows for computing the projection of a matrix onto the Stiefel manifold or low-rank approximations (as @ilayn mentioned) via Eckart–Young–Mirsky. While iterative methods based on Lanczos can be more efficient at times, this might not be always the case. For example, on GPUs, iterative methods are incredibly slow, but rather fast GPU implementations of the SVD exist. Given that a number of the frameworks that will hopefully follow the array API support GPU, this is certainly something to keep in mind. In short, I have encountered the thin SVD in many different applications as a building block for other algorithms, and in all the applications that I have come across, the thin SVD was used. That being said, my experience is certainly biased towards the fields I have studied. As such, it would be helpful if other people could share examples on which the full SVD is useful, as I do not know of any in my field, and there was just one in the SciPy code base. |
Pardon my poor English, but aren't these two statements contradictory? 😂 |
Edited :) |
Based on consortium meeting minutes from 2021-07-29, it was decided to keep the current default of |
My 2 cents on this. If your input is super wide/tall, then having |
Yeah we don't even have |
Problem
The current default behaviour of
linalg.svd
computes the full decomposition by settingfull_matrices=True
by default. On the other hand, the default behaviour oflinalg.qr
specifiesmode="reduced"
by default.Proposal
Change de default to
full_matrices=False
inlinalg.svd
. In most cases the reduced SVD is good enough. Even more, it’s better to do less work by default and just make the more expensive operation opt-in.cc @rgommers @mruberry
The text was updated successfully, but these errors were encountered: