private void TrainPersonNeuralNetwork(
            Dictionary<Person, List<double[]>[]> trainingMfccs,
            Dictionary<Person, List<double[]>[]> testMfccs,
            double[] input, double[][] answer, Person person,
            PerceptronWrapper network)
        {
            GnuPlot plot = new GnuPlot(
                person.FullName,
                @"D:\GIT\nnetwork_mini_pw\charts\plot_" + person.FullName.Replace(' ', '_') + ".png"
                );
            plot.BeginPlot();

            List<double[]>[] personMfccs = null;
            int iterations = 0;

            while (iterations < MaxIterationCounts) {
                double expectedAnswer;

                if (Random.NextDouble() < algorithmParams.TCoef) {
                    expectedAnswer      = 0.0d;
                    Person otherPerson  = SelectOtherPerson(person);
                    personMfccs         = trainingMfccs[otherPerson];
                }
                else {
                    expectedAnswer      = 1.0d;
                    personMfccs         = trainingMfccs[person];
                }

                DrawInputData(input, personMfccs);

                double scale            = Math.Sqrt(1.0 + iterations);
                double newLearningRate  = algorithmParams.LearningRate / scale;
                double newMomentum      = algorithmParams.Momentum / scale;

                answer[0][0] = expectedAnswer;
                network.Train(newLearningRate, 1, newMomentum,
                    new[] { input },
                    answer);

                iterations++;

                if (iterations % 1000 == 0) {
                    double testResult   = TestPersonNeuralNetwork(person, testMfccs, input);
                    double learnResult  = TestPersonNeuralNetwork(person, trainingMfccs, input);
                    AddPlotPoint(plot, iterations, learnResult, testResult);

                    if (testResult <= TestSetMaxError)
                    {
                        break;
                    }
                }
            }

            plot.AddAlgorithmParamsToTitle(algorithmParams);
            plot.End2Plot();
        }
        private void CreateNeuralNetworks()
        {
            neuralNetworks = new Dictionary<Person, PerceptronWrapper>();

            int                 inputSize       = GetNetworksInputSize();
            ICollection<int>    hiddenLayers    = GetLayersCount(inputSize);

            foreach (var person in people) {
                var perceptron = new PerceptronWrapper(inputSize, hiddenLayers, NeuralNetworkOutputSize, UseBias,
                                                       UseUniPolarActivationFunction);
                neuralNetworks.Add(person, perceptron);
            }
        }