diff --git a/index.html b/index.html new file mode 100644 index 0000000..3a5501d --- /dev/null +++ b/index.html @@ -0,0 +1,713 @@ + + + + + \ No newline at end of file diff --git a/m.test.js b/m.test.js index 09d9042..3183373 100644 --- a/m.test.js +++ b/m.test.js @@ -98,6 +98,7 @@ Deno.test("Single.Affine", ()=> assertEquals(t.length, 2, "correct dimensions"); assertEquals(t[0], 0.5) assertEquals(t[1], 1.1, "correct placement"); + console.log(t); }); Deno.test("Single.Subtract", ()=> { diff --git a/m.ts b/m.ts index f09c07d..a6882d2 100644 --- a/m.ts +++ b/m.ts @@ -38,11 +38,18 @@ const Methods = { Pad: (inCloud:Cloud.M):Cloud.M=> {inCloud.forEach((row:Cloud.V)=> row.push(1)); return inCloud; }, Unpad: (inCloud:Cloud.M):Cloud.M=> {inCloud.forEach((row:Cloud.V)=> row.pop()); return inCloud; } }, + Test: + { + Dot:(v1:Cloud.V, v2:Cloud.V):number=> + { + return v1.reduce((sum, current, index)=> sum + current*v2[index]); + } + }, Single: { Subtract: (inV1:Cloud.V, inV2:Cloud.V):Cloud.V=> inV1.map((component, i)=> component-inV2[i]), Multiply: (inV1:Cloud.V, inV2:Cloud.V):Cloud.V=> inV1.map((component, i)=> component*inV2[i]), - Affine: (inV:Cloud.V, inMatrix:Cloud.M):Cloud.V=> inMatrix.map((row:Cloud.V)=> row.reduce((sum, current, index)=> sum + current*inV[index])) + Affine: (inV:Cloud.V, inMatrix:Cloud.M):Cloud.V=> inMatrix.map((row:Cloud.V)=> row.reduce((sum, current, index)=> sum + current*inV[index], 0)) }, Batch: { diff --git a/nn.test.js b/nn.test.js index b7e7dff..f86af35 100644 --- a/nn.test.js +++ b/nn.test.js @@ -1,25 +1,57 @@ import { assert, assertEquals } from "https://deno.land/std@0.102.0/testing/asserts.ts"; import { Label, Forward, Backward } from "./nn.ts"; import { default as M } from "./m.ts"; +import { default as Methods } from "./m.ts"; let training = []; let stages = []; let layers = []; -Deno.test("NN.Label", ()=> +let typeA = [ + [ 0.1, 0.05], + [ 0.0, -0.06] +]; +let typeB = [ + [ 0.99, 0.85], + [ 1.2, 1.05] +]; + + +Deno.test("check.forward", ()=> { - Label(training, - [ + let training = []; + let stages = []; + let layers = [ + [ + [-0.43662948305036675, -0.368590640707799, -0.23227179558890843], + [-0.004292653969505622, 0.38670055222186317, -0.2478421495365568], + [0.738181366836224, 0.3389203747353555, 0.4920200816404332] + ], + [ + [0.5793881115472015, 0.9732593374796092, 0.15207639877016987, -0.5356575655337803] + ] + ]; + + let typeA = [ [ 0.1, 0.05], [ 0.0, -0.06] - ], - [1]); - Label(training, - [ + ]; + let typeB = [ [ 0.99, 0.85], [ 1.2, 1.05] - ], - [0]); + ]; + + Label(training, typeA, [1]); + stages.push(training[0]); + Forward(stages, layers); + console.log(stages); +}); + +/* +Deno.test("NN.Label", ()=> +{ + Label(training, typeA, [1]); + Label(training, typeB, [0]); stages.push(training[0]); console.log(training); assertEquals(training.length, 2, "input and output sets created"); @@ -30,12 +62,10 @@ Deno.test("NN.Label", ()=> Deno.test("NN.Backward", ()=> { - - let layer1 = M.Create.Box([0, 0, 0], [1, 1, 1], 2); - let layer2 = M.Create.Box([0, 0, 0], [1, 1, 1], 1); + let layer1 = M.Create.Box([-1, -1, -1], [1, 1, 1], 2); + let layer2 = M.Create.Box([-1, -1, -1], [1, 1, 1], 1); let copy1 = M.Create.Clone(layer1); let copy2 = M.Create.Clone(layer2); - layers.push(layer1); layers.push(layer2); @@ -56,3 +86,4 @@ Deno.test("NN.Forward", ()=> }); +*/ \ No newline at end of file