-
Greetings! I hope this message finds you well. I'm implementing an InPort that receives signals from multiple OutPorts and concatenates these inputs instead of the default summation behaviour. However, I couldn't find detailed information or examples in the documentation or on the web. I came across the tutorial Connect Processes and Ports, but the section title ("Connect multiple InPorts from a single OutPort") seems misleading or oversimplifying this topic. The tutorial doesn't provide information on how to override or customise the behaviour of ports for this use case. Could you provide guidance or examples on configuring an InPort to concatenate incoming signals along a specified axis (e.g., using ConcatPort or another approach)? Or does this require overriding methods in the PyProcessModel (e.g., recv)? (I've tried something in this direction, and it does not work as expected) What are the best practices for handling multiple incoming signals? I'd greatly appreciate any insights or references to additional resources to help with this! Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hello @jcrvz, I've recently been trying to accomplish the same thing, but it looks like it might not be implemented yet. When I tried something similar to the following: s_out: list[OutPort]
s_in: InPort
concat_port = s_out[0].concat_with(s_out[1:], axis=0)
concat_port.connect(s_in) I get the following error when running the network:
What I've been doing to get around this, is splitting my synapse layer in a list of separate processes, one for each of the separate inputs. The code is a lot uglier, but I am able to compile and run networks this way. Best, |
Beta Was this translation helpful? Give feedback.
After some playing around with Python's
__new__
method, I created a prototype class for dynamically creating a concatenation process.The classes
AbstractConcatenator
andPyAbstractConcatenatorModel
are the actual Lava process and model. The classesConcatenator
andPyConcatenatorModel
use__new__
to dynamically create subclasses of the process and model, then add the required ports before creating the process and model. The prototype only supports concatenating N imports of shape (1,) to a single output of shape (N,). It's only a proof of concept, but I think it should be straightforward to extend it to other inputs.Here's the code for the prototype:
"""Script demonstrating dynamically …