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
andGraphHolder
.See also
For an overview of computational graphs in Rockpool, see Computational graphs in Rockpool.
Attributes overview
The input nodes attached to this module
The output nodes attached to this module
An arbitrary name attached to this specific
GraphModule
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 moduleadd_output
(node)Add a
GraphNode
as an output of this moduleRemove all
GraphNode
s as inputs of this moduleRemove all
GraphNode
s as outputs of this moduleremove_input
(node)Remove a
GraphNode
as an input of this moduleremove_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
orGraphModule
subclass, with new input and outputGraphNode
s created automaticallyUse this factory method to construct a new
GraphModule
from scratch, which needs new input and outputGraphNode
s created automatically. This helper method will be inherited by newGraphModule
subclasses, and will act as factory methods also for your customGraphModule
subclass.- Parameters
size_in (int) β The number of input
GraphNode
s to create and attachsize_out (int) β The number of output
GraphNode
s to create and attachname (str, optional) β An arbitrary name to attach to this
GraphModule
, defaults to Nonecomputational_module (Optional[Module], optional) β A rockpool computational module that forms the βgeneratorβ of this graph module, defaults to None
- Returns
The newly constructed
GraphModule
orGraphModule
subclass- Return type
- 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.
- computational_module: Anyο
The computational module that acts as the source for this graph module
- Type
- 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.