Skip to content
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

Question about torch.lstsq and torch.linalg.lstsq #128952

Open
Kidleyh opened this issue Jun 18, 2024 · 1 comment
Open

Question about torch.lstsq and torch.linalg.lstsq #128952

Kidleyh opened this issue Jun 18, 2024 · 1 comment
Labels
module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@Kidleyh
Copy link

Kidleyh commented Jun 18, 2024

My pytorch version is 1.12.1.
I used torch.lstsq(A, B)[0][B.shape[1]] and torch.linalg.lstsq(B, A).solution and the results are different. I want to get the answer of the former. How should I use torch.linalg.lstsq to get it?

cc @jianyuh @nikitaved @pearu @mruberry @walterddr @xwang233 @lezcano

@NicolasHug NicolasHug transferred this issue from pytorch/vision Jun 18, 2024
@albanD albanD added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul labels Jun 19, 2024
@lezcano
Copy link
Collaborator

lezcano commented Jun 19, 2024

Can you update to the lastest release? Chances are that the bug is already fixed in the lastest release.

If it has not, can you provide a self-contained reproducer of the issues?

Also, note that the fact that even if the returned matrices are different, X = linalg.lstsq(A, B) just guarantees that torch.allclose(A @ X, B). There may be many matrices X that may solve this equation though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants