From 7e92bd5b292b99c5f5a3f1b05d2870be32732d92 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 11 Jun 2023 23:21:46 -0500 Subject: add memory --- src/mind/topology.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/mind/topology.test.js') diff --git a/src/mind/topology.test.js b/src/mind/topology.test.js index 5867763..fbe1862 100644 --- a/src/mind/topology.test.js +++ b/src/mind/topology.test.js @@ -187,3 +187,26 @@ test('arbitrary hidden neurons', () => { ], ]); }); + + +test('memory', () => { + const n = network(0, 1, 1).connect(0, 0, -0.5).connect(0, 1, 2); + + expect(n.compute([], [1])).toEqual([ + [ Math.tanh( 2 * Math.tanh( -0.5 * 1 ) ) ], + [ Math.tanh( -0.5 * 1) ], + ]); +}); + + +test('memory and input', () => { + const n = network(1, 1, 1) + .connect(0, 1, 1) + .connect(1, 1, 1) + .connect(1, 2, 1); + + expect(n.compute([2], [-1])).toEqual([ + [ Math.tanh( Math.tanh( 2-1 ) ) ], + [ Math.tanh( 2-1 ) ], + ]); +}); -- cgit v1.2.1