reservoirpy.ops.link_feedback#
- class reservoirpy.ops.link_feedback(node, feedback, inplace=False, name=None)[source]#
Create a feedback connection between the feedback node and node. Feedbacks nodes will be called at runtime using data from the previous call.
This is not an in-place operation by default. This function will copy node and then sets the copy _feedback attribute as a reference to feedback node. If inplace is set to True, then node is not copied and the feedback is directly connected to node. If feedback is a list of nodes or models, then all nodes in the list are first connected to a
Concat
node to create a model gathering all data from all nodes in a single feedback vector.You can also perform this operation using the
<<
operator:node1 = node1 << node2 # with feedback from a Model node1 = node1 << (fbnode1 >> fbnode2) # with feedback from a list of nodes or models node1 = node1 << [fbnode1, fbnode2, ...]
Which means that a feedback connection is now created between node1 and node2. In other words, the forward function of node1 depends on the previous output of node2:
\[\mathrm{node1}(x_t) = \mathrm{node1}(x_t, \mathrm{node2}(x_{t - 1}))\]You can also use this function to define feedback:
node1 = link_feedback(node1, node2) # without copy (node1 is the same object throughout) node1 = link_feedback(node1, node2, inplace=True, name="n1_copy")
- Parameters:
- Returns:
A node instance taking feedback from feedback.
- Return type:
- Raises:
If node is a
Model
. Models can not receive feedback. - If any of the feedback nodes are not_Node
instances.