Exemple #1
0
        public void Train(double expectedOutput, double learningRate)
        {
            //var input = inputFunction.CalculateInput(Inputs);
            var output = CalculateOutput();

            //error = expectedOutput - output;
            var error = CalculateError(output, expectedOutput);
            var slope = activationFunction.CalculateSlope(output);

            //adjustment = (error * slope) * learningrate
            var adjustment = CalculateAdjustment(error, slope, learningRate);

            //UpdateWeightsAndBiases(input);
            for (int i = 0; i < Inputs.Count; i++)
            {
                Inputs[i].UpdateWeight(adjustment);
            }

            var newOutput = CalculateOutput();

            IsCorrect = expectedOutput == Math.Round(output);
        }