Exemplo n.º 1
0
        /// <summary>
        /// Calculate the gradient value of this neuron, by multiply the error with the derivative
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public double CalculateGradient(double?target = null)
        {
            if (target == null)
            {
                return(Gradient = OutputSynapses.Sum(a => a.OutputNeuron.Gradient * a.Weight) * Sigmoid.Derivative(Value));
            }

            return(Gradient = CalculateError(target.Value) * Sigmoid.Derivative(Value));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Calculates and updates the current value stored in this neuron, by taking the output value of input neurons mutiplied by their weight, plus a bias
 /// </summary>
 /// <returns>the calculated value</returns>
 public virtual double CalculateValue()
 {
     return(Value = Sigmoid.Output(InputSynapses.Sum(a => a.Weight * a.InputNeuron.Value) + Bias));
 }