You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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()
The text was updated successfully, but these errors were encountered: