graph.GraphModuleBase

class graph.GraphModuleBase(input_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], output_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], name: str, computational_module: Any)[source]

Bases: object

Base class for graph modules

You should use the β€œpublic facing” base classes GraphModule and GraphHolder.

See also

For an overview of computational graphs in Rockpool, see Computational graphs in Rockpool.

__init__(input_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], output_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], name: str, computational_module: Any) None

Attributes overview

input_nodes

The input nodes attached to this module

output_nodes

The output nodes attached to this module

name

An arbitrary name attached to this specific GraphModule

computational_module

The computational module that acts as the source for this graph module

Methods overview

__init__(input_nodes,Β output_nodes,Β name,Β ...)

add_input(node)

Add a GraphNode as an input source to this module

add_output(node)

Add a GraphNode as an output of this module

clear_inputs()

Remove all GraphNode s as inputs of this module

clear_outputs()

Remove all GraphNode s as outputs of this module

remove_input(node)

Remove a GraphNode as an input of this module

remove_output(node)

Remove a GraphNode as an output of this module

__init__(input_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], output_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode], name: str, computational_module: Any) None
classmethod _factory(size_in: int, size_out: int, name: Optional[str] = None, computational_module: Optional[Any] = None, *args, **kwargs) graph.graph_base.GraphModuleBase[source]

Build a new GraphModule or GraphModule subclass, with new input and output GraphNode s created automatically

Use this factory method to construct a new GraphModule from scratch, which needs new input and output GraphNode s created automatically. This helper method will be inherited by new GraphModule subclasses, and will act as factory methods also for your custom GraphModule subclass.

Parameters
  • size_in (int) – The number of input GraphNode s to create and attach

  • size_out (int) – The number of output GraphNode s to create and attach

  • name (str) – An arbitrary name to attach to this GraphModule

  • computational_module (Module) – A rockpool computational module that forms the β€œgenerator” of this graph module

  • *args – Any additional arguments to pass to the specific subclass constructor

  • **kwargs –

    Any additional arguments to pass to the specific subclass constructor

Returns

The newly constructed GraphModule or GraphModule subclass

Return type

GraphModule

add_input(node: graph.graph_base.GraphNode) None[source]

Add a GraphNode as an input source to this module

Parameters

node (GraphNode) – The node to add as an input source. This node will be appended after the last current input node.

add_output(node: graph.graph_base.GraphNode) None[source]

Add a GraphNode as an output of this module

Parameters

node (GraphNode) – The node to add as an output channel. This node will be appended after the last current output node.

clear_inputs() None[source]

Remove all GraphNode s as inputs of this module

clear_outputs() None[source]

Remove all GraphNode s as outputs of this module

computational_module: Any

The computational module that acts as the source for this graph module

Type

Module

input_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode]

The input nodes attached to this module

Type

SetList[GraphNode]

name: str

An arbitrary name attached to this specific GraphModule

Type

str

output_nodes: graph.graph_base.SetList[graph.graph_base.GraphNode]

The output nodes attached to this module

Type

SetList[GraphNode]

remove_input(node: graph.graph_base.GraphNode) None[source]

Remove a GraphNode as an input of this module

Parameters

node (GraphNode) – The node to remove. If this node exists as an input to the module, it will be removed.

remove_output(node: graph.graph_base.GraphNode) None[source]

Remove a GraphNode as an output of this module

Parameters

node (GraphNode) – The node to remove. If this node exists as an output of the module, it will be removed.