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

Problem with multiple inputs #68

Closed
AlexStasik opened this issue Apr 29, 2022 · 2 comments · Fixed by #69
Closed

Problem with multiple inputs #68

AlexStasik opened this issue Apr 29, 2022 · 2 comments · Fixed by #69
Assignees
Labels
bug Something isn't working
Projects

Comments

@AlexStasik
Copy link

Hi,

thanks a lot for the great library. I am having some stupid problem, but when trying to do multiple inputs, I get some error messages. The code is actually from the documentation, could you help me what I am doing wrong here?

from reservoirpy.nodes import Reservoir, Input
import numpy as np
source1, source2 = Input(name="s1", input_dim=5,), Input(name="s2", input_dim=3,)
res1, res2 = Reservoir(100), Reservoir(100)
model = source1 >> [res1, res2] & source2 >> [res1, res2]
outputs = model.run({"s1": np.ones((10, 5)), "s2": np.ones((10, 3))})

And the code leads to the following error message:


AttributeError Traceback (most recent call last)
/var/folders/bl/r4t30wmj1dd63sm1kdt1fs_40000gn/T/ipykernel_62311/3650941534.py in
6 res1, res2 = Reservoir(100), Reservoir(100)
7 model = source1 >> [res1, res2] & source2 >> [res1, res2]
----> 8 outputs = model.run({"s1": np.ones((10, 5)), "s2": np.ones((10, 3))})

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/model.py in run(self, X, forced_feedbacks, from_state, stateful, reset, shift_fb, return_states)
810 )
811
--> 812 self.initialize_on_sequence(X, forced_feedbacks_)
813
814 states = allocate_returned_states(self, X, return_states)

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/model.py in _initialize_on_sequence(self, X, Y)
337 y_init = np.atleast_2d(Y[0])
338
--> 339 self.initialize(x_init, y_init)
340
341 def _call(self, x=None, return_states=None, *args, **kwargs):

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/model.py in initialize(self, x, y)
673 """
674 self._is_initialized = False
--> 675 self._initializer(self, x=x, y=y)
676 self.reset()
677 self._is_initialized = True

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/model.py in initializer(model, x, y)
220 # (no real call, only zero states)
221 for node in model.nodes:
--> 222 node.initialize(x=data[node].x, y=data[node].y)
223
224 # second, probe feedback demanding nodes to

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/node.py in initialize(self, x, y)
672 if not self.is_initialized:
673 x_init, y_init = _init_vectors_placeholders(self, x, y)
--> 674 self._initializer(self, x=x_init, y=y_init)
675 self.reset()
676 self._is_initialized = True

~/miniforge3/envs/reservoir/lib/python3.9/site-packages/reservoirpy/nodes/reservoirs/base.py in initialize(reservoir, x, sr, input_scaling, bias_scaling, input_connectivity, rc_connectivity, W_init, Win_init, bias_init, input_bias, seed, **kwargs)
115 ):
116 if x is not None:
--> 117 reservoir.set_input_dim(x.shape[1])
118
119 dtype = reservoir.dtype

AttributeError: 'list' object has no attribute ‘shape'

@nTrouvain
Copy link
Collaborator

Hello @AlexStasik,

Thank you for this bug report. I was able to reproduce it, and sadly I can't find a workaround for now. I will release a correction as soon as possible this week.

@AlexStasik
Copy link
Author

Hello @nTrouvain ,

thanks a lot for the reply and thanks so much for looking into the issue. The package is great, looking forward to test it with the fix.

@nTrouvain nTrouvain added the bug Something isn't working label May 2, 2022
@nTrouvain nTrouvain self-assigned this May 2, 2022
@nTrouvain nTrouvain added this to Issues in v0.3 via automation May 2, 2022
@nTrouvain nTrouvain moved this from Issues to In progress in v0.3 May 2, 2022
@nTrouvain nTrouvain linked a pull request May 8, 2022 that will close this issue
@PAUL-BERNARD PAUL-BERNARD moved this from In progress to Done (previous release) in v0.3 Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
v0.3
Done (previous release)
Development

Successfully merging a pull request may close this issue.

2 participants