# brainpy.nn.operations.ff_connect#

Connect two sequences of Node instances to form a brainpy.nn.base.Network instance. senders output will be used as input for receivers in the created network. This is similar to a function composition operation:

$network(x) = (sender \circ receiver)(x) = receiver(sender(x))$

You can also perform this operation using the >> operator:

network = sender >> receiver


Or using this function:

network = ff_connect(sender, receiver)

• sender and receiver can also be brainpy.nn.base.Network instances. In this case, the new brainpy.nn.base.Network created will contain all nodes previously contained in all the networks, and link all node1 outputs to all node2 inputs. This allows to chain the >> operator:

step1 = node0 >> node1  # this is a network
step2 = step1 >> node2  # this is another

• node1 can finally be lists or tuples of nodes. In this case, all node1 outputs will be linked to a Concat node to concatenate them, and the Concat node will be linked to all node2 inputs:

# many-concat-to-one
network = [node1, node2, ..., node] >> node_out

• If you do not want to concatenate all input nodes, you can use set to wrap all input nodes at once. Then, node2 will receive multiple inputs defined in node1:

# many-to-one
network = {node1, node2, ..., node_N} >> node_out

• In the case of “one-to-many” feedforward connection, node2 only support a set of node. Using list or tuple to wrap multiple receivers will concatenate all nodes in the receiver end. This will cause errors:

# wrong operation of one-to-many
network = node_in >> {node1, node2, ..., node_N}

# correct operation of one-to-many
network = node_in >> {node1, node2, ..., node_N}

• “many-to-many” connection is also allowed.

You can still use the >> operator in this situation, except for many-to-many nodes connections:

# many-to-many
{node1, node2, ..., node} >> {node1, node2, ..., node}

Parameters
• senders (Node, sequence of Node) – Nodes or sequence of nodes to connect feedforward connections.

• receivers (Node, sequence of Node) – Nodes or sequence of nodes to connect feedforward connections.

• inplace (bool) – Whether inplace update the node.

• name (str, optional) – Name for the chaining Network.

• need_detect_cycle (bool) – Whether we need to detect cycles exit in the final network.

Returns

A brainpy.nn.base.Network instance chaining the nodes.

Return type

Network

Notes

Be careful to how you link the different nodes: reservoirpy does not allow to have circular dependencies between them:

network = node1 >> node2  # fine
network = node1 >> node2 >> node1  # raises! data would flow in
# circles forever...