summaryrefslogtreecommitdiff
path: root/src/mind/topology.test.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-06-12 09:24:56 -0500
committersanine <sanine.not@pm.me>2023-06-12 09:24:56 -0500
commitdb486d5d9a762532f5c7bd45920b01ab63cd08bd (patch)
tree3ec0d1d1715d92ee9fb09a4d54768d2517b65c3d /src/mind/topology.test.js
parent251f39da74c8d5707eaeef8d5e63ce442720b01f (diff)
clean up network_compute and add input validation
Diffstat (limited to 'src/mind/topology.test.js')
-rw-r--r--src/mind/topology.test.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mind/topology.test.js b/src/mind/topology.test.js
index fbe1862..b272040 100644
--- a/src/mind/topology.test.js
+++ b/src/mind/topology.test.js
@@ -210,3 +210,23 @@ test('memory and input', () => {
[ Math.tanh( 2-1 ) ],
]);
});
+
+
+test('input and state must be the correct size', () => {
+ const n = network(2, 1, 1)
+ .connect(0, 2, 1)
+ .connect(1, 2, 1)
+ .connect(2, 3, 1);
+
+ // wrong input size
+ expect(() => n.compute([], [4])).toThrow();
+ expect(() => n.compute([1], [4])).toThrow();
+ expect(() => n.compute([1, 1, 1], [4])).toThrow();
+
+ // wrong state size
+ expect(() => n.compute([1, 1], [])).toThrow();
+ expect(() => n.compute([1, 1], [4, 4])).toThrow();
+
+ // prove correct sizes work
+ n.compute([1, 1], [4]);
+});