8000 A possible subtle mistake related to code implementation of nplr · Issue #159 · state-spaces/s4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A possible subtle mistake related to code implementation of nplr #159

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
MichaelY310 opened this issue Mar 25, 2025 · 0 comments
Open

Comments

@MichaelY310
Copy link

In s4/src/models/hippo/hippo.py line 240

W_im, V = torch.linalg.eigh(AP*-1j) # (..., N) (..., N, N)

to calculate the complex part of the eigenvalue and eigenvectors, instead of AP, the skew symmetric part, which is AP - torch.diag(torch.diag(AP)), should be eigendecomposed. So I think this line should be replaced by

W_im, V = torch.linalg.eigh((AP-torch.diag(torch.diag(AP)))*-1j)

However, the mistake is very subtle here since the diagonal value -0.5 is very small comparing to other entries in AP. The revision only decreases the reconstruction error of A by about 0.00001 if I set cdtype to torch.complex128. And there is no difference at all if I use the default setting torch.complex64. But if the mistake indeed present, it may cause greater errors when methods other than LegS with matrices having small matrix norms are used.

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

No branches or pull requests

1 participant
0