Exemple #1
0
        protected virtual void CalculateGradient()
        {
            var weightedSum = 0.0;

            foreach (var outputConnection in _outputConnections)
            {
                weightedSum += outputConnection.TargetNeuron.Gradient * outputConnection.Weight;
            }
            this.Gradient = weightedSum * _activationFunction.CalculateDerivative(GetWeightedInput());
        }
Exemple #2
0
        private double Activation(double[] activations, double[,] weights, double bias, ActivationFunction activationFunction, int outputIndex)
        {
            var zj = 0D;

            for (var inputIndex = 0; inputIndex < activations.Length; inputIndex++)
            {
                zj += activations[inputIndex] * weights[inputIndex, outputIndex];
            }

            zj += bias;

            switch (activationFunction)
            {
            case ActivationFunction.Sigmoid:
                return(sigmoidActivationFunction.CalculateDerivative(zj));

            default:
                return(zj);
            }
        }
 public float CalculateDerivative(float value)
 {
     return(_activationFunction.CalculateDerivative(value));
 }