From 980a5350b5a4845db2bd5d6feb9f463a3c1a3aa6 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 11 Jun 2023 22:50:42 -0500 Subject: add hidden neuron state --- src/mind/topology.test.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/mind/topology.test.js') diff --git a/src/mind/topology.test.js b/src/mind/topology.test.js index e1c5f87..7612c3d 100644 --- a/src/mind/topology.test.js +++ b/src/mind/topology.test.js @@ -137,3 +137,42 @@ test('multiple input network', () => { [], ]); }); + + +test('multiple outputs', () => { + const n = network(4, 0, 2) + .connect(0, 4, -1) + .connect(1, 4, 1) + .connect(2, 5, -1) + .connect(3, 5, 1); + + expect(n.compute([1,2,3,5], [])).toEqual([ + [ Math.tanh(2-1), Math.tanh(5-3) ], + [], + ]); +}); + + +test('hidden neurons', () => { + const n = network(4, 2, 1) + .connect(0, 4, -1) + .connect(1, 4, 1) + .connect(2, 5, -1) + .connect(3, 5, 1) + .connect(4, 6, -1) + .connect(5, 6, 1); + + expect(n.compute([1,2,3,5], [ 0, 0 ])).toEqual([ + [ Math.tanh( Math.tanh(5-3) - Math.tanh(2-1) ) ], + [ Math.tanh(2-1), Math.tanh(5-3) ], + ]); +}); + + +//test('arbitrary hidden neurons', () => { +// const n = network(1, 2, 1) +// .connect(0, 1, 1) +// .connect(1, 2, -1) +// .connect(2, 3, 2) +// .connect(3, 4, -2); +//}); -- cgit v1.2.1