I have used Neataptic library to evolve structure for XOR like in the instructions on their github page.
The actual results seems right however when I visualize the nodes (most of the time) there is no hidden layer - only 2 input nodes and 1 output, therefore I assume it should not work. Any idea what's wrong?
var network = new neataptic.Network(2,1);
var trainingSet = [
{ input: [0,0], output: [0] },
{ input: [0,1], output: [1] },
{ input: [1,0], output: [1] },
{ input: [1,1], output: [0] }
];
async function abc() {
await network.evolve(trainingSet, {
equal: true,
error: 0.03
});
document.getElementById("app").innerHTML = "0 ⊕ 0 = " +
network.activate([0,0]) + "<br />0 ⊕ 1 = " +
network.activate([0,1]) + "<br />1 ⊕ 0 = " +
network.activate([1,0]) + "<br />1 ⊕ 1 = " +
network.activate([1,1]);
drawGraph(network.graph(500, 400), '#draw');
}
abc();
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
height: 100vh;
}
#app {
vertical-align: top;
display: inline-block;
padding: 15px;
width: 20%;
height: 100%;
}
#draw {
vertical-align: top;
display: inline-block;
width: 80%;
height: 100%;
}
<link rel="stylesheet" type="text/css" href="https://rawgit.com/wagenaartje/neataptic/master/graph/graph.css">
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://marvl.infotech.monash.edu/webcola/cola.v3.min.js"></script>
<script src="https://combinatronics.com/wagenaartje/neataptic/master/graph/graph.js"></script>
<script src="https://wagenaartje.github.io/neataptic/cdn/1.4.7/neataptic.js"></script>
<div id="app">
</div><svg id="draw" width="600px" height="450px" />
I have contacted the creator of Neataptic library and this is the answer to my question:
... recall that mutations can also change the squashing function of the final node. Yes, the default logistic squashing function can't handle XOR, but a sinusoidal function can!