Nodes¶
Abstract Nodes¶
-
class
cgp.node.
Node
(idx: int, addresses: List[int])[source]¶ Bases:
object
Base class for input/output and hidden nodes.
-
property
addresses
¶
-
property
arity
¶
-
property
idx
¶
-
property
max_arity
¶
-
property
output
¶
-
property
output_str
¶
-
property
-
class
cgp.node.
OperatorNode
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.Node
Base class of hidden nodes.
Subclasses provide the atomic operations of the computational graph.
-
format_output_str_numpy
(graph: CartesianGraph) → None[source]¶ Format output string for NumPy representation.
-
format_output_str_sympy
(graph: CartesianGraph) → None[source]¶ Format output string for SymPy representation.
-
format_output_str_torch
(graph: CartesianGraph) → None[source]¶ Format output string for PyTorch representation.
-
property
parameter_str
¶
-
Input/Output Nodes¶
-
class
cgp.node_input_output.
InputNode
(idx: int, input_nodes: List[int])[source]¶ Bases:
cgp.node.Node
An input node of the computational graph.
-
format_output_str_numpy
(graph: CartesianGraph) → None[source]¶ Format output string for NumPy representation.
-
-
class
cgp.node_input_output.
OutputNode
(idx: int, input_nodes: List[int])[source]¶ Bases:
cgp.node.Node
An output node of the computational graph.
-
format_output_str_numpy
(graph: CartesianGraph) → None[source]¶ Format output string for NumPy representation.
-
Operator Nodes¶
-
class
cgp.node_impl.
Add
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that adds its two inputs.
-
class
cgp.node_impl.
ConstantFloat
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node with a constant output.
-
class
cgp.node_impl.
Div
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that devides its first by its second input.
-
class
cgp.node_impl.
IfElse
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that outputs the value of its second input if its first input is non-negative, and the value of its third input otherwise.
-
class
cgp.node_impl.
Mul
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that multiplies its two inputs.
-
class
cgp.node_impl.
Parameter
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that provides a parametrized constant output.
The value of the parameter can be adapted via local search and is passed on from parents to their offspring.
-
class
cgp.node_impl.
Pow
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that raises its first to the power of its second input.
-
class
cgp.node_impl.
Sub
(idx: int, addresses: List[int])[source]¶ Bases:
cgp.node.OperatorNode
A node that substracts its second from its first input.