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

OptDMD.predict does not work with default argument factorization='evd' #226

Open
cgahr opened this issue Nov 19, 2021 · 0 comments
Open
Labels

Comments

@cgahr
Copy link

cgahr commented Nov 19, 2021

If I run OptDMD with default argument factorization='evd', the error 'OptDMD' object has no attribute '_eigs' is raised. This is an easy fix, replace self._eigs with self.eigs. However, doing so introduces a new bug.

Running OptDMD with factorization='svd' works fine.

Describe the bug

dmd = OptDMD(svd_rank=7)
dmd.fit(X)
dmd.predict(X)

The last statement causes an error.

To Reproduce
see previous code snippet.

Expected behavior
There shouldn't be an exception.

Output

Traceback (most recent call last):
  ...
  File "/home/user/anaconda3/envs/test/lib/python3.9/site-packages/pydmd/optdmd.py", line 235, in predict
    Y = np.linalg.multi_dot(
  File "<__array_function__ internals>", line 5, in multi_dot
  File "/home/user/anaconda3/envs/test/lib/python3.9/site-packages/numpy/linalg/linalg.py", line 2724, in multi_dot
    _assert_2d(*arrays)
  File "/home/user/anaconda3/envs/test/lib/python3.9/site-packages/numpy/linalg/linalg.py", line 190, in _assert_2d
    raise LinAlgError('%d-dimensional array given. Array must be '
numpy.linalg.LinAlgError: 1-dimensional array given. Array must be two-dimensional

Additional context
I looked into what causes this bug and there seems to be a mismatch in dimensions:

Y = np.linalg.multi_dot(
    [
        self._output_space,
        np.diag(self.eigs),
        self._input_space.T.conj(),
        X,
    ]
)

We have the following shapes:

self._output_space.shape = (128, 7)
np.diag(self.eigs).shape = (7, 7)
self._input_space.T.conj().shape = (7, )
X.shape = (128, )

This does not match. My best guess is, that the shape of the third matrix should be self._input_space.shape == (128, 7) so that the result after the multiplication has a shape of (128, ).

@cgahr cgahr added the bug label Nov 19, 2021
@cgahr cgahr changed the title 'OptDMD.predict' does not work with default argument factorization='evd' OptDMD.predict does not work with default argument factorization='evd' Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant