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

Weird results #234

Open
clive-g-brown opened this issue Jun 1, 2020 · 1 comment
Open

Weird results #234

clive-g-brown opened this issue Jun 1, 2020 · 1 comment
Labels
🕷️ bug Something isn't working 📖 documentation Regarding the documentation of a thing ✨ enhancement Something could be better 👀 high priority Prioritized item

Comments

@clive-g-brown
Copy link

clive-g-brown commented Jun 1, 2020

Description

When running the vanilla xor, I get widly varying results after training, yet with a very low measured error. almost random results with low error, both in debugger and when printing to console.

Screenshots

5 consecutive runs (error is line 1):

-0
[ 1 ]
[ 1 ]
[ -1 ]
[ 1 ]

-0
[ 0 ]
[ 1 ]
[ 0 ]
[ 0 ]

0.00019156340528790638
[ 0.5116388521017431 ]
[ 0.3428954069380361 ]
[ 0.5116388521017431 ]
[ 0.3428954069380361 ]

-0
[ 0.34173701088298947 ]
[ 0.005307673690185314 ]
[ 0.0017903267041861595 ]
[ 6.842180212331013e-7 ]

-0
[ 1 ]
[ 0 ]
[ 0 ]
[ 0 ]

Files

A list of relevant files for this issue. This will help people navigate the project and offer some clues of where to start.

To Reproduce

const chai = require('chai')
const assert = chai.assert

let { Network, methods } = require('@liquid-carrot/carrot');

// this network learns the XOR gate (through neuro-evolution)
async function execute () {
// no hidden layers...
var network = new Network(2,1);

// XOR dataset
var trainingSet = [
{ input: [0,0], output: [0] },
{ input: [0,1], output: [1] },
{ input: [1,0], output: [1] },
{ input: [1,1], output: [0] }
];

const results = await network.evolve(trainingSet, {
mutation: methods.mutation.FFW,
equal: true,
error: 0.0003,
elitism: 10,
mutation_rate: 0.3,
threads: 5
});
console.log(results.error)
assert.isBelow(results.error, 0.0003);
// and it works!
console.log(network.activate([0,0])); // 0.2413
console.log(network.activate([0,1])); // 1.0000
console.log(network.activate([1,0])); // 0.7663
console.log(network.activate([1,1])); // 0.008
}

execute();

/// threads 1, 1000 iterations -- logging

teration 100 fitness -0.0011220021193443105 error 0.0005220021193443104
iteration 200 fitness -0.0006363003302362967 error 0.0000363003302362966
iteration 300 fitness -0.0006277835038999049 error 0.00002778350389990485
iteration 400 fitness -0.0006250023524746145 error 0.00002500235247461448
iteration 500 fitness -0.0006244568900950992 error 0.000024456890095099146
iteration 600 fitness -0.0006058503711863999 error 0.00000585037118639982
iteration 700 fitness -0.0006041840989964885 error 0.000004184098996488483
iteration 800 fitness -0.0006020429427010222 error 0.0000020429427010221213
iteration 900 fitness -0.0006014404264906937 error 0.000001440426490693686
iteration 1000 fitness -0.0006014404264906937 error 0.000001440426490693686
0.000001440426490693686
[ 0.99596362676882 ]
[ 0.496402339649377 ]
[ 0.41957367383984256 ]
[ 0.034813165252755914 ]
neon_carrot % node test1.js
iteration 100 fitness -0.0012000000000000001 error -0
iteration 200 fitness -0.0012000000000000001 error -0
iteration 300 fitness -0.0012000000000000001 error -0
iteration 400 fitness -0.0012000000000000001 error -0
iteration 500 fitness -0.0012000000000000001 error -0
iteration 600 fitness -0.0012000000000000001 error -0
iteration 700 fitness -0.0011 error -0
iteration 800 fitness -0.0011 error -0
iteration 900 fitness -0.0011 error -0
iteration 1000 fitness -0.0011 error -0
-0
[ 0.27516382951966845 ]
[ 0.3855840206635007 ]
[ 0.27516382951966845 ]
[ 0.3855840206635007 ]
neon_carrot % node test1.js
iteration 100 fitness -0.0006000000000000001 error -0
iteration 200 fitness -0.0006000000000000001 error -0
iteration 300 fitness -0.0006000000000000001 error -0
iteration 400 fitness -0.0006000000000000001 error -0
iteration 500 fitness -0.0006000000000000001 error -0
iteration 600 fitness -0.0006000000000000001 error -0
iteration 700 fitness -0.0006000000000000001 error -0
iteration 800 fitness -0.0006000000000000001 error -0
iteration 900 fitness -0.0006000000000000001 error -0
iteration 1000 fitness -0.0006000000000000001 error -0
-0
[ 1 ]
[ -1 ]
[ 1 ]
[ 1 ]

// then after many tries it gets it right

iteration 100 fitness -0.0004567252593608716 error 0.0002567252593608716
iteration 200 fitness -0.00021686014209889781 error 0.000016860142098897805
iteration 300 fitness -0.00020795225452568586 error 0.000007952254525685855
iteration 400 fitness -0.0002029582806041947 error 0.0000029582806041947003
iteration 500 fitness -0.0002029582806041947 error 0.0000029582806041947003
iteration 600 fitness -0.00020277357041923415 error 0.0000027735704192341406
iteration 700 fitness -0.00020082334109185242 error 8.233410918524102e-7
iteration 800 fitness -0.00020082334109185242 error 8.233410918524102e-7
iteration 900 fitness -0.00020082334109185242 error 8.233410918524102e-7
iteration 1000 fitness -0.00020082334109185242 error 8.233410918524102e-7
8.233410918524102e-7
[ 0.0002002736795891913 ]
[ 0.9990157960831416 ]
[ 1.0006023497616376 ]
[ 0.0013862799989068364 ]

@raimannma raimannma added ✨ enhancement Something could be better 👀 high priority Prioritized item 📖 documentation Regarding the documentation of a thing 🕷️ bug Something isn't working labels Jun 3, 2020
@clive-g-brown
Copy link
Author

Hi all. I tried this again, using the example given in the docs (same as above), just with console outputs. Its still generating basically random outputs, only occasionally right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕷️ bug Something isn't working 📖 documentation Regarding the documentation of a thing ✨ enhancement Something could be better 👀 high priority Prioritized item
Projects
None yet
Development

No branches or pull requests

2 participants