From 3d9b692d4da16d0203263a0e5ed30c6fd2307258 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Sat, 31 Jul 2021 10:37:17 -0400 Subject: [PATCH] rounded output --- index.js | 23 +++++------------------ iris.js | 2 +- nn.ts | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 362726e..b3c16f8 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,10 @@ import { Build, Learn, Label } from "./nn.ts"; import { default as Clean } from "./iris.js"; -const [ inputs, labels ] = Clean(); +let [ inputs, labels ] = Clean(); +let layers = Build(4, 10, 3); +let errors = Learn(inputs, layers, labels, 500, 0.1); +let output = Label(inputs, layers, true); -const layers = Build(4, 100, 3); -const errors = Learn(inputs, layers, labels, 400, 0.1); -const output = Label(inputs, layers); - -let Two = inCloud => -{ - inCloud.forEach(row=> - { - row.forEach((cell, i)=> - { - row[i] = (Math.round(cell * 100) / 100).toFixed(2); - }); - }); - return inCloud; -} - -console.log(Two(output)); +console.log(output); \ No newline at end of file diff --git a/iris.js b/iris.js index 3ac537e..80e4778 100644 --- a/iris.js +++ b/iris.js @@ -6,7 +6,7 @@ export default () => let min = [999, 999, 999, 999]; let max = [-99, -99, -99, -99]; - Data.split("\n").forEach((inRowValue, inRowIndex)=> + DataBig.split("\n").forEach((inRowValue, inRowIndex)=> { let currentInput = []; let currentLabel = []; diff --git a/nn.ts b/nn.ts index 8c07f32..75c887a 100644 --- a/nn.ts +++ b/nn.ts @@ -58,10 +58,21 @@ const Build = (...inLayers:Array):N => } return output; }; -const Label = (inData:Cloud.M, inLayers:N):Cloud.M => +const Label = (inData:Cloud.M, inLayers:N, inRound:boolean):Cloud.M => { let stages:N = Forward(M.Create.Padded(inData), inLayers); - return stages[stages.length-1]; + let output = stages[stages.length-1]; + if(inRound) + { + output.forEach(row=> + { + row.forEach((cell, i)=> + { + row[i] = (Math.round(cell * 100) / 100); + }); + }); + } + return output; }; const Learn = (inData:Cloud.M, inLayers:N, inLabels:Cloud.M, inIterations:number, inRate:number):Cloud.M => {