adjust ok

This commit is contained in:
TreetopFlyer 2021-07-29 09:19:27 -04:00
parent 09053ebf97
commit 23e71542f2
2 changed files with 7 additions and 3 deletions

View File

@ -709,7 +709,10 @@ NN.Network.Stochastic = function(inNetwork, inTrainingSet, inIterations)
let stage1 = NN.Layer.Forward(layer1, typeA);
let stage1Error = NN.Layer.Error(layer1, goals);
let stage1Back = NN.Layer.Backward(layer1, stage1Error);
console.log(stage1Error);
console.log("matrix before", layer1.Forward.Matrix);
NN.Layer.Adjust(layer1, 0.1);
console.log("matrix after", layer1.Forward.Matrix);
</script>

5
nn.ts
View File

@ -34,8 +34,6 @@ const Backward = (inStages:N, inLayers:N, inGoals:Cloud.M, inRate:number):N =>
let i:number;
let errorBack:Cloud.M = M.Batch.Subtract(inStages[inStages.length-1], inGoals);
console.log(errorBack);
for(i=inLayers.length-1; i>=0; i--)
{
let layerInput:Cloud.M = inStages[i];
@ -43,12 +41,15 @@ const Backward = (inStages:N, inLayers:N, inGoals:Cloud.M, inRate:number):N =>
let errorScaled:Cloud.M = M.Batch.Multiply(errorBack, M.Batch.Derivative(layerOutput));
errorBack = M.Batch.Affine(errorScaled, M.Create.Transpose(inLayers[i]));
console.log("matrix before:", inLayers[i]);
errorScaled.forEach((inScaledError:Cloud.V, inIndex:number)=> {
const deltas = M.Batch.Scale(M.Create.Outer(layerInput[inIndex], inScaledError), inRate);
inLayers[i] = M.Batch.Subtract(inLayers[i], deltas);
});
console.log("matrix after:", inLayers[i]);
}
return inLayers;
};