pyneat.graph_utils module¶
Utility functions for various graph operations.
-
pyneat.graph_utils.
creates_cycle
(connections, test)[source]¶ Checks to see if adding the test connection to the network would create a cycle.
Parameters: Returns: True if ‘test’ creates a cycle, False otherwise.
Return type:
-
pyneat.graph_utils.
find_path
(sources, goals, connections)[source]¶ Try to find a path between the any of the start nodes and any of the goal nodes.
Parameters: Returns: A list of each node along the discovered path.
Return type:
-
pyneat.graph_utils.
group_layers
(inputs, outputs, biases, connections, nodes)[source]¶ - Group nodes together into layers that can be evaluated in parallel by a
- feed-forward neural network.
i.e. nodes in the same layer are independent conditional on the nodes in previous layers.
Parameters: - inputs (list) – The keys of the input nodes.
- outputs (list) – The keys of the output nodes.
- biases (list) – The keys of the bias nodes.
- connections (list) – A list of (node in key, node out key) pairs for each expressed connection.
- nodes (set) – The set of nodes required for calculating the output value.
Returns: - A list of sets that contain the node keys for the nodes in each
layer.
Return type:
-
pyneat.graph_utils.
required_for_output
(inputs, biases, outputs, connections, nodes)[source]¶ Check to see if a node is required for computing the output of the network.
- A hidden node h in a NN is required if the following hold:
- there is a path from h to an output node
- there is a path from an input node to h
Shortcuts can be taken if there is a path from h1 to h2 and h1 has been marked as required.
Parameters: Returns: The set of nodes required for computing the output of the network.
Return type: