public void ProcessError(Vector error) { Matrix weightUpdate = error.Times(lastInput.Transpose()); layer.AcceptNewWeightUpdate(weightUpdate); Vector biasUpdate = layer.GetBiasVector().Plus(error); layer.AcceptNewBiasUpdate(biasUpdate); }
public static Vector CalculateBiasUpdates(LayerSensitivity layerSensitivity, double alpha) { Layer layer = layerSensitivity.GetLayer(); Matrix biasUpdateMatrix = layerSensitivity.GetSensitivityMatrix() .Times(alpha) .Times(-1.0); Vector result = new Vector(biasUpdateMatrix.GetRowDimension()); for (int i = 0; i < biasUpdateMatrix.GetRowDimension(); ++i) { result.SetValue(i, biasUpdateMatrix.Get(i, 0)); } layer.AcceptNewBiasUpdate(result.CopyVector()); return(result); }
public Vector CalculateBiasUpdates(LayerSensitivity layerSensitivity, double alpha, double momentum) { Layer layer = layerSensitivity.GetLayer(); Matrix biasUpdateMatrixWithoutMomentum = layerSensitivity.GetSensitivityMatrix().Times(alpha).Times(-1.0); Matrix biasUpdateMatrixWithMomentum = layer.GetLastBiasUpdateVector() .Times(momentum) .Plus(biasUpdateMatrixWithoutMomentum .Times(1.0 - momentum)); Vector result = new Vector(biasUpdateMatrixWithMomentum.GetRowDimension()); for (int i = 0; i < biasUpdateMatrixWithMomentum.GetRowDimension(); ++i) { result.SetValue(i, biasUpdateMatrixWithMomentum.Get(i, 0)); } layer.AcceptNewBiasUpdate(result.CopyVector()); return(result); }