rounded output
This commit is contained in:
parent
9fcfb9115d
commit
3d9b692d4d
23
index.js
23
index.js
@ -1,23 +1,10 @@
|
|||||||
import { Build, Learn, Label } from "./nn.ts";
|
import { Build, Learn, Label } from "./nn.ts";
|
||||||
import { default as Clean } from "./iris.js";
|
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);
|
console.log(output);
|
||||||
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));
|
|
2
iris.js
2
iris.js
@ -6,7 +6,7 @@ export default () =>
|
|||||||
let min = [999, 999, 999, 999];
|
let min = [999, 999, 999, 999];
|
||||||
let max = [-99, -99, -99, -99];
|
let max = [-99, -99, -99, -99];
|
||||||
|
|
||||||
Data.split("\n").forEach((inRowValue, inRowIndex)=>
|
DataBig.split("\n").forEach((inRowValue, inRowIndex)=>
|
||||||
{
|
{
|
||||||
let currentInput = [];
|
let currentInput = [];
|
||||||
let currentLabel = [];
|
let currentLabel = [];
|
||||||
|
15
nn.ts
15
nn.ts
@ -58,10 +58,21 @@ const Build = (...inLayers:Array<number>):N =>
|
|||||||
}
|
}
|
||||||
return output;
|
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);
|
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 =>
|
const Learn = (inData:Cloud.M, inLayers:N, inLabels:Cloud.M, inIterations:number, inRate:number):Cloud.M =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user