|
@@ -9,8 +9,8 @@
|
|
|
#network {
|
|
#network {
|
|
|
background: #ccc;
|
|
background: #ccc;
|
|
|
border: 1px solid red;
|
|
border: 1px solid red;
|
|
|
- width: 80%;
|
|
|
|
|
- height: 400px;
|
|
|
|
|
|
|
+ width: 640px;
|
|
|
|
|
+ height: 480px;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|
|
|
</head>
|
|
</head>
|
|
@@ -29,18 +29,13 @@
|
|
|
</body>
|
|
</body>
|
|
|
<script src="brain-browser.js"></script>
|
|
<script src="brain-browser.js"></script>
|
|
|
<script type="text/javascript">
|
|
<script type="text/javascript">
|
|
|
- // provide optional config object (or undefined). Defaults shown.
|
|
|
|
|
- const config = {
|
|
|
|
|
- binaryThresh: 0.5,
|
|
|
|
|
- hiddenLayers: [5], // array of ints for the sizes of the hidden layers in the network
|
|
|
|
|
- activation: "relu", // supported activation types: ['sigmoid', 'relu', 'leaky-relu', 'tanh'],
|
|
|
|
|
- leakyReluAlpha: 0.01, // supported for activation type 'leaky-relu'
|
|
|
|
|
- // inputSize: 2,
|
|
|
|
|
- // outputSize: 2,
|
|
|
|
|
|
|
+ const svg_config = {
|
|
|
|
|
+ height: 480,
|
|
|
|
|
+ width: 640,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// create a simple feed forward neural network with backpropagation
|
|
// create a simple feed forward neural network with backpropagation
|
|
|
- const net = new brain.NeuralNetwork(config);
|
|
|
|
|
|
|
+ const net = new brain.NeuralNetwork();
|
|
|
|
|
|
|
|
net.train([
|
|
net.train([
|
|
|
{ input: [0, 0], output: [0] },
|
|
{ input: [0, 0], output: [0] },
|
|
@@ -50,15 +45,14 @@
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
const input = [1, 0];
|
|
const input = [1, 0];
|
|
|
-
|
|
|
|
|
const output = net.run(input); // [0.987]
|
|
const output = net.run(input); // [0.987]
|
|
|
|
|
|
|
|
document.getElementById("output").innerHTML =
|
|
document.getElementById("output").innerHTML =
|
|
|
- "Input:" + input + "<br/>" + "output is " + output;
|
|
|
|
|
|
|
+ `Input: [${input}] <br/>Output is ${output}`;
|
|
|
|
|
|
|
|
document.getElementById("network").innerHTML = brain.utilities.toSVG(
|
|
document.getElementById("network").innerHTML = brain.utilities.toSVG(
|
|
|
net,
|
|
net,
|
|
|
- config
|
|
|
|
|
|
|
+ svg_config
|
|
|
);
|
|
);
|
|
|
</script>
|
|
</script>
|
|
|
</html>
|
|
</html>
|