コード例 #1
0
        public void Backpropagation(decimal[] inputs, decimal[] answers)
        {
            // FEEDFORWARD
            decimal[] hiddenOutputs = HiddenLayer.CalculateOutputs(inputs);
            decimal[] outputOutputs = OutputLayer.CalculateOutputs(hiddenOutputs);

            // BACKPROPAGATION
            decimal[] outputErros       = OutputLayer.CalculateErrors(outputOutputs, answers);
            decimal[] outputDerivatives = OutputLayer.CalculateDerivatives(outputOutputs);
            decimal[] outputGradients   = OutputLayer.CalculateGradients(outputErros, outputDerivatives);

            decimal[] hiddenDerivatives = HiddenLayer.CalculateDerivatives(hiddenOutputs);
            decimal[] hiddenGradients   = HiddenLayer.CalculateGradients(OutputLayer, outputGradients, hiddenDerivatives);

            OutputLayer.Adjust(hiddenOutputs, outputGradients);
            HiddenLayer.Adjust(inputs, hiddenGradients);
        }