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

Where does the randomness come from #133

Closed
zonglunli7515 opened this issue Sep 2, 2023 · 2 comments
Closed

Where does the randomness come from #133

zonglunli7515 opened this issue Sep 2, 2023 · 2 comments

Comments

@zonglunli7515
Copy link

Hi,

I think I fixed the input and reservoir weights but I still observed the difference in the internal state after running the following code multiple times. Where does the randomness come from? Thanks in advance.

from reservoirpy.nodes import Reservoir
import numpy as np
import matplotlib.pyplot as plt

def normal_w(n, m, **kwargs):
np.random.seed(42)
W_res = np.random.normal(0, 1, size=(n, m))
rhoW = max(abs(np.linalg.eig(W_res)[0]))
return rhoW*W_res/rhoW

def normal_win(n, m, **kwargs):
np.random.seed(43)
W_in = np.random.normal(0, 1, size=(n, m))
return W_in

X = np.sin(np.linspace(0, 6*np.pi, 100)).reshape(-1, 1)
reservoir = Reservoir(50, lr=1, Win=normal_win, W=normal_w)
states = reservoir.run(X)
plt.plot(states[:,1])
reservoir = reservoir.reset()

@PAUL-BERNARD
Copy link
Contributor

Hi @zonglunli7515 ,

The randomness in your reservoir state comes from the input bias of the reservoir. If you want a deterministic behavior, you can set a value for bias, disable input bias by setting input_bias=False, or set a seed when creating your Reservoir.

Let me know if that helps

@zonglunli7515
Copy link
Author

Thanks a lot! I overconcentrated on noise parameters and overlooked this!

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

3 participants