Skip to content

Use torch.linalg.lstsq instead of torch.lstsq #6

Description

@KrzysiekDD

In line 226 of the anfis.py, a runtime error arises:

RuntimeError: This function was deprecated since version 1.9 and is now removed. `torch.lstsq` is deprecated in favor of `torch.linalg.lstsq`.
`torch.linalg.lstsq` has reversed arguments and does not return the QR decomposition in the returned tuple (although it returns other information about the problem).

This is an issue that arises when swapping .gels with lstsq, which fixes the original deprecation, however with torch > 1.9 torch.linalg.lstsq is needed because another deprecation arises.

Swapping:
coeff_2d, _ = torch.lstsq(y_actual_2d, weighted_x_2d)
for:
coeff_2d = torch.linalg.lstsq(weighted_x_2d, y_actual_2d).solution
fixes the problem.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions