예제 #1
0
        public TestingMode(Perceptron _perceptron)
        {
            teachingPatterns = new TeachingPatterns();
            perceptron       = _perceptron;

            perceptron.uploadWeights();

            for (int j = 1; j <= 4; j++)
            {
                input = teachingPatterns.getTeachingPattern(j);

                expected = input; // W tym przypdku wartości wyjściowe to wejściowe

                perceptron.forwardPropagation(input);
                perceptron.addSumSquaredError(expected);

                string strInput = "";
                for (int k = 0; k < perceptron.layers[0].input.Length; k++)
                {
                    strInput += Convert.ToString(perceptron.layers[0].input[k]) + " ";
                }
                string strOutput = "";
                for (int l = 0; l < perceptron.layers.Last().output.Length; l++)
                {
                    strOutput += Convert.ToString(Math.Round(perceptron.layers.Last().output[l], 4)) + " ";
                }

                Console.WriteLine(String.Format("input: {0} output: {1}", strInput, strOutput));
            }
            perceptron.estimateSumSquaredError();

            Console.WriteLine("błąd średniokwadratowy: {0}\n", perceptron.getTotalSumSquaredError());
        }
예제 #2
0
        public TeachingMode(Perceptron _perceptron, int _epoch, int _logJump, bool _isRandomOrderPatterns, double _learnFactor, double _momentum, double _errorLevel = 0.0)
        {
            perceptron = _perceptron;
            perceptron.randomWeights();

            for (int i = 0; i <= _epoch; i++)
            {
                teachingPatterns = new TeachingPatterns();

                for (int j = 1; j <= 4; j++)
                {
                    if (_isRandomOrderPatterns == true)
                    {
                        input = teachingPatterns.getRandomTeachingPattern();
                    }
                    else
                    {
                        input = teachingPatterns.getTeachingPattern(j);
                    }

                    expected = input; // W tym przypdku wartości wyjściowe to wejściowe

                    /**** BACK PROPAGATION ALGORITHM ****/
                    perceptron.backPropagation(_learnFactor, _momentum, input, expected);
                    /************************************/

                    perceptron.addSumSquaredError(expected);
                }
                perceptron.estimateSumSquaredError();

                if (i % _logJump == 0)
                {
                    string strInput = "";
                    for (int k = 0; k < perceptron.layers[0].input.Length; k++)
                    {
                        strInput += Convert.ToString(perceptron.layers[0].input[k]) + " ";
                    }
                    string strOutput = "";
                    for (int l = 0; l < perceptron.layers.Last().output.Length; l++)
                    {
                        strOutput += Convert.ToString(Math.Round(perceptron.layers.Last().output[l], 4)) + " ";
                    }

                    Console.WriteLine(String.Format("input: {0} output: {1}", strInput, strOutput));

                    perceptron.saveErrorToFile();
                }

                if (perceptron.getTotalSumSquaredError() <= _errorLevel || i == _epoch)
                {
                    Console.WriteLine("błąd średniokwadratowy: {0}\n założony poziom błędu: {1}\n epoki: {2}",
                                      perceptron.getTotalSumSquaredError(), _errorLevel, i);
                    Console.WriteLine(perceptron.ToString());
                    break;
                }

                perceptron.resetSumSquaredError();
            }
        }
예제 #3
0
        public ClassificationTestingMode(Perceptron _perceptron)
        {
            cts        = new ClassificationTeachingSet();
            perceptron = _perceptron;

            perceptron.uploadWeights();

            for (int i = 1; i <= 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    input    = cts.getTestingPattern(i, j);
                    expected = cts.getOutput(i);

                    perceptron.forwardPropagation(input);
                    perceptron.addSumSquaredError(expected);

                    string strInput = "";
                    for (int k = 0; k < perceptron.layers[0].input.Length; k++)
                    {
                        strInput += Convert.ToString(perceptron.layers[0].input[k]) + " ";
                    }

                    string strExpected = "";
                    for (int k = 0; k < expected.Length; k++)
                    {
                        strExpected += Convert.ToString(expected[k]);
                    }

                    string strOutput = "";
                    for (int k = 0; k < perceptron.layers.Last().output.Length; k++)
                    {
                        strOutput += Convert.ToString(Math.Round(perceptron.layers.Last().output[k], 4)) + " ";
                    }


                    Console.WriteLine(String.Format("input: {0} expected {1} output: {2}", strInput, strExpected, strOutput));
                }

                perceptron.estimateSumSquaredError();
            }


            Console.WriteLine("błąd średniokwadratowy: {0}\n", perceptron.getTotalSumSquaredError());
        }