question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resulted network does not seem to work

See original GitHub issue

Hi, I ran the Neat Python XOR example and a neural network it found has the following properties:

Best individual in generation 22 meets fitness threshold - complexity: (2, 8) Number of evaluations: 3450

Best genome: Nodes: NodeGene(id=0, type=INPUT, bias=0.0, response=4.924273, activation=sigmoid) NodeGene(id=1, type=INPUT, bias=0.0, response=4.924273, activation=sigmoid) NodeGene(id=2, type=OUTPUT, bias=0.0, response=4.921960812206318, activation=sigmoid) NodeGene(id=3, type=HIDDEN, bias=-2.340619398413843, response=4.930091408143276, activation=sigmoid) NodeGene(id=4, type=HIDDEN, bias=0.4674809078722945, response=4.918937894580367, activation=sigmoid) Connections: ConnectionGene(in=0, out=2, weight=1.0534262789427578, enabled=True, innov=0) ConnectionGene(in=1, out=2, weight=-1.6479324848766828, enabled=True, innov=1) ConnectionGene(in=0, out=3, weight=-3.5479647367966765, enabled=True, innov=2) ConnectionGene(in=3, out=2, weight=5.970619032226201, enabled=True, innov=3) ConnectionGene(in=1, out=3, weight=4.634338591600734, enabled=True, innov=4) ConnectionGene(in=0, out=4, weight=0.19203601809123594, enabled=True, innov=5) ConnectionGene(in=4, out=2, weight=-0.6588709650159562, enabled=True, innov=6) ConnectionGene(in=4, out=3, weight=-3.0010419817357072, enabled=True, innov=8) Node order: [4, 3]

Output: expected 0.00000 got 0.11990 expected 1.00000 got 1.00000 expected 1.00000 got 0.92939 expected 0.00000 got 0.00395 {2} {2} {0, 1, 3, 4} {0, 1, 2, 3, 4}

However, when trying to implement the neural network in Python, I don’t get the same results:


import math

def sigmoid(x):
    f = 1 / (1 + math.exp(-x))
    return f


node0 = 1
node1 = 1
node2 = 0

node3_bias = -2.340619398413843
node4_bias = 0.4674809078722945

connection_0_2 = 1.0534262789427578
connection_1_2 = -1.6479324848766828
connection_0_3 = -3.5479647367966765
connection_3_2 = 5.970619032226201
connection_1_3 = 4.634338591600734
connection_0_4 = 0.19203601809123594
connection_4_2 = -0.6588709650159562
connection_4_3 = -3.0010419817357072


def main():
    activated_node4 = sigmoid(node4_bias * 1 +
                              node0 * connection_0_4)
    activated_node3 = sigmoid(node3_bias * 1 +
                              activated_node4 * connection_4_3 +
                              node0 * connection_0_3 +
                              node1 * connection_1_3)
    activated_node2 = sigmoid(activated_node4 * connection_4_2 +
                              activated_node3 * connection_3_2 +
                              node1 * connection_1_2 +
                              node0 * connection_0_2)

    print("The value is: ", activated_node2)


if __name__ == "__main__":

    main()

For nodes 1 and 1 I get:

The value is: 0.30957048732254944

which does not match the expected output above.

Can anyone please help me with some pointers as to what I am getting wrong?

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
radu-nedelcu-decommented, Mar 5, 2017

Hi guys,

Thank you so much! I was ignoring both the response as I did not know it is required and the sigmoid activation function, thinking it would be identical.

It’s working fine now.

0reactions
CodeReclaimerscommented, Mar 5, 2017

Glad to help–it’s always those little back-end details that are hard to spot right away. 😃 Thanks for taking an evolved network and doing the experiment of using it elsewhere!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Device Can't Connect to Wi-Fi? Here's What to Do
Avoid the dreaded "Can't connect to network" error by using the tips in this guide.
Read more >
What To Do If Your Internet is Not Working: 9 Ways ... - Rent.com
Step 1: Unplug the router and the modem from the power source. If your modem or router has a battery backup, make sure...
Read more >
Home Network Problems? 8 Diagnostic Tricks and Fixes to Try
1. Power Cycle Everything and Check Other Devices ... There's no need to get upset about network issues right away, as the fix...
Read more >
Fix Wi-Fi connection issues in Windows - Microsoft Support
Network troubleshooting on your device · Select Search on the taskbar, and type command prompt. The Command Prompt button will appear. · At...
Read more >
9 most common network issues and how to solve them
Business networks are complex, and many things can go wrong that disrupt network performance. End users often complain about what appears to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found