示例#1
0
        public void ProcessError(Vector error)
        {
            Matrix weightUpdate = error.Times(lastInput.Transpose());

            layer.AcceptNewWeightUpdate(weightUpdate);

            Vector biasUpdate = layer.GetBiasVector().Plus(error);

            layer.AcceptNewBiasUpdate(biasUpdate);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }