Neataptic XOR 仅用 3 个节点求解

Neataptic XOR solving only with 3 nodes

我已经使用 Neataptic 库来演化 XOR 的结构,就像他们 github page.

上的说明一样

实际结果似乎是正确的但是当我可视化节点时(大部分时间)没有隐藏层 - 只有 2输入节点和 1 个输出,因此我认为它不应该工作。知道出了什么问题吗?

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" />

您只定义了两个输入层和一个输出层。重新阅读文档以了解如何正确添加隐藏层。使用感知器或 lstm

我已经联系了 Neataptic 库的创建者,这是我的问题的答案:

... 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!