network #1

Merged
SethTrowbridge merged 13 commits from network into master 2021-07-29 16:16:32 -04:00
2 changed files with 14 additions and 20 deletions
Showing only changes of commit 6c186bc6e4 - Show all commits

View File

@ -2,16 +2,9 @@ import { assert, assertEquals } from "https://deno.land/std@0.102.0/testing/asse
import { Label, Forward, Backward } from "./nn.ts";
import { default as M } from "./m.ts";
const input = [
[ 0.1, 0.05],
[ 0.0, -0.06]
[ 0.99, 0.85],
[ 1.2, 1.05]
];
const training = [];
const stages = [];
const layers = [];
let training = [];
let stages = [];
let layers = [];
Deno.test("NN.Label", ()=>
{
@ -38,19 +31,21 @@ Deno.test("NN.Label", ()=>
Deno.test("NN.Backward", ()=>
{
layers.push(M.Create.Box([0, 0, 0], [1, 1, 1], 4));
layers.push(M.Create.Box([0, 0, 0, 0, 0], [1, 1, 1, 1, 1], 1));
let layer1 = M.Create.Box([0, 0, 0], [1, 1, 1], 4);
let layer2 = M.Create.Box([0, 0, 0, 0, 0], [1, 1, 1, 1, 1], 1);
let copy1 = M.Create.Clone(layer1);
let copy2 = M.Create.Clone(layer2);
let copy1 = M.Create.Clone(layers[0]);
let copy2 = M.Create.Clone(layers[1]);
layers.push(layer1);
layers.push(layer2);
for(let i=0; i<1000; i++)
for(let i=0; i<100; i++)
{
Backward(stages, layers, training[1], 0.1);
Backward(stages, layers, training[1], 0.01);
}
assert(layers[0][0][0] != copy1[0][0][0], "first matrix has changed");
assert(layers[1][0][0] != copy2[0][0][0], "second matrix has changed");
console.log(layer1, copy1);
assert(layer1[0][0] != copy1[0][0], "first matrix has changed");
assert(layer1[1][0] != copy2[1][0], "second matrix has changed");
});
Deno.test("NN.Forward", ()=>

1
nn.ts
View File

@ -38,7 +38,6 @@ const Backward = (inStages:N, inLayers:N, inGoals:Cloud.M, inRate:number):void =
let layerMatrix:Cloud.M = inLayers[i];
let layerInput:Cloud.M = inStages[i];
let layerOutput:Cloud.M = inStages[i+1];
let errorScaled:Cloud.M = M.Batch.Multiply(errorBack, M.Batch.Derivative(layerOutput));
errorBack = M.Batch.Affine(errorScaled, M.Create.Transpose(layerMatrix));