PyDMD / PyDMD

Python Dynamic Mode Decomposition

Home Page:https://pydmd.github.io/PyDMD/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares

Lindge-Zou opened this issue · comments

Thank you for your work, it's a great project. I am using the BOP-DMD you developed to reconstruct and predict the real trajectory data Data. Data is a two-dimensional ndarray of 104*540 (104 in space and 540 in time). Calculatively, the svd_rank that can explain 90% of the variance is 282. So I'm trying to reconstruct the data using the following code:

print('Loading Data Set...')
Data, delay, dtype, hwylength, hwy, delt = load_data(data)
n = Data.shape[1]  # time dimension 540
n_to_forecast = 20  # forecast time length 20
n_to_reconstruct = n - n_to_forecast  # reconstruct time length 520
m = Data.shape[0]  # space dimension 104
reconstruct_Data = Data[:, :n_to_reconstruct]  # (104, 520)
time_reconstruct_list = np.arange(0, n_to_reconstruct * delt, delt)  # (520,)
time_forecast_list = np.arange(n_to_reconstruct * delt, n * delt, delt)  # (20,)
print('Data loaded successfully.')

bopdmd = BOPDMD(svd_rank=282, num_trials=100, varpro_opts_dict={"tol": 0.0115})
delay_bopdmd = hankel_preprocessing(bopdmd, d=delay)  # delay=7
num_t = len(time_reconstruct_list) - delay + 1
delay_bopdmd.fit(Data, t=time_reconstruct_list[:num_t])

numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares
Is there something wrong with my data structure? I'm sure the dimension of the Data is len(spatial)*len(temporal).

Hi @Lindge-Zou !

So from my own experience, this issues tends to pop up when you aren't using enough data at each trial of BOP-DMD.

With that in mind, I would recommend one of the following:

  • Increase the trial_size parameter of BOPDMD. Sometimes something as high as trial_size=0.8 (i.e. using 80% of your data per trial) is necessary for good BOP-DMD results.
  • Try regular Optimized DMD, which you can do with the BOPDMD module if you set num_trials=0. This is because Optimized DMD always uses all of the available data.

Thank you for your guidance, it has been very helpful. Thanks again!