brainpy.nn.operations.merge#

brainpy.nn.operations.merge(node, *other_nodes, inplace=False, name=None, need_detect_cycle=True)[source]#

Merge different Node or brainpy.nn.base.Network instances into a single brainpy.nn.base.Network instance.

Node instances contained in the network to merge will be gathered in a single network, along with all previously defined connections between them, if they exists.

You can also perform this operation using the & operator:

network = (node1 >> node2) & (node1 >> node3))

This is equivalent to:

network = merge((node1 >> node2), (node1 >> node3))

The inplace operator can also be used:

network &= other_network
Parameters
  • node (Network, Node) – First node or network to merge.

  • *other_nodes (Network, Node) – All nodes to merge.

  • inplace (bool, default to False) – If True, then will update node inplace. If node is not a Network instance, this parameter will causes the function to raise an error.

  • name (str, optional) – Name of the resulting Network.

  • need_detect_cycle (bool) – Whether need to detect the cycle defined in the graph.

Returns

A new brainpy.nn.base.Network instance.

Return type

Network