cknd / pyESN

Echo State Networks in Python
MIT License
296 stars 122 forks source link

A Possible Improvement on Numerical Stability and Speed #16

Open wangzcl opened 2 years ago

wangzcl commented 2 years ago

Hello Clemens, thank you for your ESN implementation, which really helps me a lot in my research. Youuse np.linalg.pinv in your evaluation of W_out at line 192, pyESN.py, which can make it unstable. When I tried to transplant it from Numpy (default float type double) to PyTorch (default float type float32), the network cannot run correctly . It may be better to use self.W_out = np.linalg.lstsq(extended_states[transient:, :], self.inverse_out_activation(teachers_scaled[transient:, :])).T or self.W_out = np.linalg.solve(extended_states[transient:, :], self.inverse_out_activation(teachers_scaled[transient:, :])).T. Thanks!