Ejemplo n.º 1
0
        /// <summary> Calculates and adds the changes to be made to this <see cref="Neuron"/> from the given <paramref name="error"/>. </summary>
        /// <param name="neuronLayerChange"> The changes to make to the containing <see cref="NeuronLayer"/>. </param>
        /// <param name="weightLayerChange"> The changes to make to the previous <see cref="WeightLayer"/>. </param>
        /// <param name="error"> The previously calculated delta. </param>
        /// <returns> The calculated delta of this <see cref="Neuron"/>. </returns>
        public float CalculateChanges(NeuronLayerChange neuronLayerChange, WeightLayerChange weightLayerChange, float error)
        {
            // Calculate the delta.
            float delta = activationFunction.ActivationDerivative(Output) * error;

            float p = activationFunction.ActivationDerivative(Output);

            if (p < 0)
            {
                throw new Exception();
            }

            // Add the changes to be made.
            addChanges(neuronLayerChange, weightLayerChange, delta);

            // Return the calculated delta.
            return(delta);
        }