Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static Matrix CalculateWeightUpdates(LayerSensitivity layerSensitivity,
                                                    Vector previousLayerActivationOrInput,
                                                    double alpha)
        {
            Layer  layer = layerSensitivity.GetLayer();
            Matrix activationTranspose = previousLayerActivationOrInput.Transpose();
            Matrix weightUpdateMatrix
                = layerSensitivity.GetSensitivityMatrix()
                  .Times(activationTranspose)
                  .Times(alpha)
                  .Times(-1.0);

            layer.AcceptNewWeightUpdate(weightUpdateMatrix.Copy());

            return(weightUpdateMatrix);
        }
        public Matrix CalculateWeightUpdates(LayerSensitivity layerSensitivity,
                                             Vector previousLayerActivationOrInput,
                                             double alpha,
                                             double momentum)
        {
            Layer  layer = layerSensitivity.GetLayer();
            Matrix activationTranspose = previousLayerActivationOrInput.Transpose();
            Matrix momentumLessUpdate
                = layerSensitivity.GetSensitivityMatrix()
                  .Times(activationTranspose)
                  .Times(alpha)
                  .Times(-1.0);
            Matrix updateWithMomentum
                = layer.GetLastWeightUpdateMatrix()
                  .Times(momentum)
                  .Plus(momentumLessUpdate.Times(1.0 - momentum));

            layer.AcceptNewWeightUpdate(updateWithMomentum.Copy());

            return(updateWithMomentum);
        }