private void TrainAllMnistImages(int nEpochMax, bool accuracy)
        {
            int counter     = 101;
            int trigger     = 50;
            int totalImages = 0;

            neuralNet.learningRate = double.Parse(teLearningRate.Text.ToString(), CultureInfo.InvariantCulture);

            for (int epoch = 0; epoch < nEpochMax; epoch++)
            {
                int n = 0;

                bool anyMoreNumbers = true;

                while (anyMoreNumbers)
                {
                    for (int expected = 0; expected < NeuralNetwork.outputLayer.outputNeurons; expected++)
                    {
                        bool   useTestingDataset = false;
                        byte[] pixels            = MnistImage.GetImageNumberPixels(expected, n, useTestingDataset);

                        currentPixels = pixels;

                        if (pixels != null)
                        {
                            TrainNetOnNumber(pixels, expected);
                            currentColumn = MnistImage.GetCol(expected, n);
                            currentRow    = MnistImage.GetRow(expected, n);
                        }
                        else
                        {
                            anyMoreNumbers = false;
                        }
                    }

                    n++;
                    totalImages++;

                    if (accuracy)
                    {
                        counter++;
                        if (counter > trigger)
                        {
                            AccuracyOfResult = Evaluation(nIterationLoop);
                            counter          = 0;
                        }
                    }
                }
            }
        }
        private string Evaluation(int nTestFactor)
        {
            neuralNet.errors.Clear();
            int n             = 0;
            int limit         = nTestFactor;
            int rightAnalysis = 0;
            int analysis      = 0;

            int[] rightNumbers = new int[10];
            int[] nNumbers     = new int[10];

            bool anyMoreNumbers = true;

            for (int expected = 0; expected < NeuralNetwork.outputLayer.outputNeurons; expected++)
            {
                rightNumbers[expected] = 0;
                nNumbers[expected]     = 0;
            }

            while (anyMoreNumbers)
            {
                anyMoreNumbers = false;

                for (int expected = 0; (expected < NeuralNetwork.outputLayer.outputNeurons); expected++)
                {
                    bool useTestingDataset = true;

                    byte[] pixels = MnistImage.GetImageNumberPixels(expected, n, useTestingDataset);

                    currentPixels = pixels;

                    if (pixels != null)
                    {
                        anyMoreNumbers = true;

                        int    estimated  = 0;
                        double confidence = 0.0;

                        if (imageHasNumber(pixels))
                        {
                            if (TestNetOnNumber(pixels, expected, out estimated, out confidence))
                            {
                                rightAnalysis++;
                                rightNumbers[expected]++;
                            }
                            analysis++;
                            nNumbers[expected]++;
                        }
                    }
                }

                n++;

                if (n > limit)
                {
                    break;
                }
            }

            double percentRight = (double)rightAnalysis / (double)analysis;

            previousAccuracySample = accuracySample;
            accuracySample         = percentRight;

            string result = Math.Round(percentRight, 4).ToString();


            if (n > nTestFactor)
            {
                TotalAccuracyOfNumbers = "";

                for (int i = 0; i < NeuralNetwork.outputLayer.outputNeurons; i++)
                {
                    double percentCorrect = ((double)rightNumbers[i] / (double)nNumbers[i]) * 100;
                    TotalAccuracyOfNumbers += "Konfidenz der Ziffer " + i.ToString() + " beträgt " + percentCorrect.ToString("0.00") + " %\r\n";
                }
            }

            return(result);
        }