Esempio n. 1
0
        //计算梯度,target是目标值,如果有目标值,则是输出节点
        public double CalculateGradient(double?target = null)
        {
            //如果没有目标值,说明是中间层
            if (target == null)
            {
                //return Gradient = OutputSynapses.Sum(a => a.OutputNeuron.Gradient * a.Weight) * Sigmoid.Derivative(OutputValue);
                return(Gradient = Error * Sigmoid.Derivative(OutputValue));
            }

            //如果有目标值,说明是输出层
            return(Gradient = Error * Sigmoid.Derivative(OutputValue));
            // return Gradient = Sigmoid.Derivative(OutputValue);
        }
Esempio n. 2
0
 //计算输出值 ,输入值加上偏置,然后应用sigmoid函数
 public virtual double CalculateValue()
 {
     this.InputValue = InputSynapses.Sum(a => a.Weight * a.InputNeuron.OutputValue);
     return(OutputValue = Sigmoid.Output(InputValue + Bias));
 }