graph.LinearWeightsο
- class graph.LinearWeights(input_nodes: rockpool.graph.graph_base.SetList[GraphNode], output_nodes: rockpool.graph.graph_base.SetList[GraphNode], name: str, computational_module: Any, weights: Union[float, numpy.ndarray, torch.Tensor], biases: Optional[Union[float, numpy.ndarray, torch.Tensor]] = None)[source]ο
Bases:
rockpool.graph.graph_base.GraphModule
A
GraphModule
that encapsulates a single set of linear weightsAttributes overview
The biases
(Nout,)
encapsulaed by this moduleThe linear weights
(Nin, Nout)
encapsulated by this moduleMethods overview
__init__
(input_nodes,Β output_nodes,Β name,Β ...)add_input
(node)Add a
GraphNode
as an input source to this module, and connect itadd_output
(node)Add a
GraphNode
as an output of this module, and connect itRemove 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 module, and disconnect itremove_output
(node)Remove a
GraphNode
as an output of this module, and disconnect it- __init__(input_nodes: rockpool.graph.graph_base.SetList[GraphNode], output_nodes: rockpool.graph.graph_base.SetList[GraphNode], name: str, computational_module: Any, weights: Union[float, numpy.ndarray, torch.Tensor], biases: Optional[Union[float, numpy.ndarray, torch.Tensor]] = None) None ο
- classmethod _convert_from(mod: rockpool.graph.graph_base.GraphModuleBase) rockpool.graph.graph_base.GraphModuleBase ο
Convert another
GraphModule
to aGraphModule
of this specific subclassYou should override this method in your subclass, to include conversion rules from other graph module classes to your specific subclass.
If you do not provide conversion rules to your specific subclass then it will not be possible to map other
GraphModule
subclasses to your subclass.- Parameters
mod (GraphModule) β A
GraphModule
orGraphModule
subclass object to convert to an object of the specific subclass.- Returns
A converted
GraphModule
subclass object, of the specific subclass on which this method was called.- Return type
- classmethod _factory(size_in: int, size_out: int, name: Optional[str] = None, computational_module: Optional[Any] = None, *args, **kwargs) rockpool.graph.graph_base.GraphModuleBase ο
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: rockpool.graph.graph_base.GraphNode) None ο
Add a
GraphNode
as an input source to this module, and connect itThe new node will be appended after the last current input node. The node will be connected with this
GraphModule
as a sink.- Parameters
node (GraphNode) β The node to add as an input source
- add_output(node: rockpool.graph.graph_base.GraphNode) None ο
Add a
GraphNode
as an output of this module, and connect itThe new node will be appended after the last current output node. The node will be connected with this
GraphModule
as a source.- Parameters
node (GraphNode) β The node to add as an output
- biases: Optional[Union[float, numpy.ndarray, torch.Tensor]] = Noneο
The biases
(Nout,)
encapsulaed by this module- Type
FloatVector
- computational_module: Moduleο
The computational module that acts as the source for this graph module
- Type
- input_nodes: SetList['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: SetList['GraphNode']ο
The output nodes attached to this module
- Type
SetList[GraphNode]
- remove_input(node: rockpool.graph.graph_base.GraphNode) None ο
Remove a
GraphNode
as an input of this module, and disconnect itThe node will be disconnected from this
GraphModule
as a sink, and will be removed from the 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: rockpool.graph.graph_base.GraphNode) None ο
Remove a
GraphNode
as an output of this module, and disconnect itThe node will be disconnected from this
GraphModule
as a source, and will be removed from the module.- Parameters
node (GraphNode) β The node to remove. If this node exists as an output to the module, it will be removed.
- weights: Union[float, numpy.ndarray, torch.Tensor]ο
The linear weights
(Nin, Nout)
encapsulated by this module- Type
FloatVector