Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net evaluation order inconsistent with connection order #1

Open
JEdward7777 opened this issue Mar 29, 2023 · 0 comments
Open

Net evaluation order inconsistent with connection order #1

JEdward7777 opened this issue Mar 29, 2023 · 0 comments

Comments

@JEdward7777
Copy link

A connection is considered valid if it is from a node to a node with a higher y.
See line 280 in brain.py in _valid_conn:
node1.y <= node2.y

However in evaluation, the nodes are evaluated in the natural list order which by inspection appear to be in .id order, not .y order.
See line 302 in brain.py in predict
for node in self.nodes:

This needs to read something like
for node in sorted(net.nodes,key=lambda node : node .y):

Without this change, randomly it evaluates nodes which have a value still set to zero because the connection goes forward through the list.
I ran into this because in my code I have a forked version of predict which runs the data through the network as a numpy array for accelerated processing and the uninitialized zero value didn't play well with slicing for the relu zeroing. As is, in your version, the library will look like it is working, but there will be nets which fail the evolution not because of a bad connection, but because the signal reads as zero when it shouldn't. You should be able to prove that this is happening by setting the default value to None on line 297 and then asserting it is not None when iterating input connections on line 314.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant