-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.js
50 lines (34 loc) · 934 Bytes
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const lib = require('./lib');
// TODO:
// build network that can quickly setup a new network
// let network = new lib.Network(3, 4, 2);
// let output = network.process(0, 1);
//
// same for layer
// layer = new lib.Layer()
// layer.process();
//
// back-propagation
//
let save = require('./examples/xor.json');
let network =
lib.deserialize(
lib.serialize(
lib.deserialize(save)
)
);
//console.log('saved', JSON.stringify(save, null, ' '));
for (let x = 0; x < 2; x++) {
for (let y = 0; y < 2; y++) {
console.log('------------------ [ new calculation ] ------------------');
network.layers[0].neurons[0].value = x;
network.layers[0].neurons[1].value = y;
network.layers.forEach(layer => {
console.log(`${layer.name}:`);
layer.neurons.forEach(neuron => {
let output = neuron.process();
console.log(`\t${neuron.name}: ${output}`);
});
});
}
}