adjust ok
This commit is contained in:
parent
09053ebf97
commit
23e71542f2
@ -709,7 +709,10 @@ NN.Network.Stochastic = function(inNetwork, inTrainingSet, inIterations)
|
|||||||
|
|
||||||
let stage1 = NN.Layer.Forward(layer1, typeA);
|
let stage1 = NN.Layer.Forward(layer1, typeA);
|
||||||
let stage1Error = NN.Layer.Error(layer1, goals);
|
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>
|
</script>
|
5
nn.ts
5
nn.ts
@ -34,8 +34,6 @@ const Backward = (inStages:N, inLayers:N, inGoals:Cloud.M, inRate:number):N =>
|
|||||||
let i:number;
|
let i:number;
|
||||||
let errorBack:Cloud.M = M.Batch.Subtract(inStages[inStages.length-1], inGoals);
|
let errorBack:Cloud.M = M.Batch.Subtract(inStages[inStages.length-1], inGoals);
|
||||||
|
|
||||||
console.log(errorBack);
|
|
||||||
|
|
||||||
for(i=inLayers.length-1; i>=0; i--)
|
for(i=inLayers.length-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
let layerInput:Cloud.M = inStages[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));
|
let errorScaled:Cloud.M = M.Batch.Multiply(errorBack, M.Batch.Derivative(layerOutput));
|
||||||
|
|
||||||
errorBack = M.Batch.Affine(errorScaled, M.Create.Transpose(inLayers[i]));
|
errorBack = M.Batch.Affine(errorScaled, M.Create.Transpose(inLayers[i]));
|
||||||
|
console.log("matrix before:", inLayers[i]);
|
||||||
|
|
||||||
errorScaled.forEach((inScaledError:Cloud.V, inIndex:number)=> {
|
errorScaled.forEach((inScaledError:Cloud.V, inIndex:number)=> {
|
||||||
const deltas = M.Batch.Scale(M.Create.Outer(layerInput[inIndex], inScaledError), inRate);
|
const deltas = M.Batch.Scale(M.Create.Outer(layerInput[inIndex], inScaledError), inRate);
|
||||||
inLayers[i] = M.Batch.Subtract(inLayers[i], deltas);
|
inLayers[i] = M.Batch.Subtract(inLayers[i], deltas);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("matrix after:", inLayers[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
return inLayers;
|
return inLayers;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user