rounded output

This commit is contained in:
TreetopFlyer 2021-07-31 10:37:17 -04:00
parent 9fcfb9115d
commit 3d9b692d4d
3 changed files with 19 additions and 21 deletions

View File

@ -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);

View File

@ -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 = [];

15
nn.ts
View File

@ -58,10 +58,21 @@ const Build = (...inLayers:Array<number>):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 =>
{