-
-
Notifications
You must be signed in to change notification settings - Fork 505
Fix FeedForwardNetwork and output bug #282
base: master
Are you sure you want to change the base?
Conversation
Finebouche
commented
May 20, 2024
- Fix FeedForwardNetwork wrong creation, where some useless node were use to create the network and some usufull ones were disregarded
- and remove the possibility for the ouput to be an input to a new node
@@ -341,7 +341,7 @@ def mutate_add_connection(self, config): | |||
possible_outputs = list(self.nodes) | |||
out_node = choice(possible_outputs) | |||
|
|||
possible_inputs = possible_outputs + config.input_keys | |||
possible_inputs = list((set(self.nodes)- set(config.output_keys)) | set(config.input_keys) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes new node from taking output nodes as inputs
neat/nn/feed_forward.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removed useless nodes from the FeedForwardNetwork
if n in required and all(a in s for (a, b) in connections if b == n): | ||
t.add(n) | ||
# select connections (a, b) where b == n | ||
connections_to_n = [(a, b) for (a, b) in connections if b == n and a in required] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the change here is that a as to be in required nodes to be considered
@@ -38,20 +38,35 @@ def required_for_output(inputs, outputs, connections): | |||
""" | |||
assert not set(inputs).intersection(outputs) | |||
|
|||
# Create a graph representation of the connections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous function wasn't working as intended
|