/// <summary>
        /// Tests the network.
        /// </summary>
        /// <param name="network">The network.</param>
        public void TestNetwork(TeachableNetwork network)
        {
            int passedTests = 0;
            int failedTests = 0;
            foreach (TestingSet testingSet in TestingCollection.Values)
            {
                network.ComputeNetworkResponse(testingSet.Input);
                double[] response = network.GetResponse();

                double max = -1;
                int index = 0;
                for (int i = 0; i < response.Length; i++)
                {
                    if (response[i] > max)
                    {
                        max = response[i];
                        index = i;
                    }
                }

                if (index == testingSet.Value)
                {
                    Console.WriteLine("Test passed: {0} recognized.", testingSet.Value);
                    passedTests++;
                }
                else
                {
                    Console.WriteLine("Test failed: {0} recognized instead {1}.", index, testingSet.Value);
                    failedTests++;
                }
            }
            Console.WriteLine("All passed tests: {0}.", passedTests);
            Console.WriteLine("All failed tests: {0}.", failedTests);
        }
        /// <summary>
        /// Teaches the network.
        /// </summary>
        /// <param name="network">The network.</param>
        public void TeachNetwork(TeachableNetwork network)
        {
            int era = 0;
            double errorForWholeEra = 0;
            int currentIterationCount = 0;

            do
            {
                era++;
                errorForWholeEra = 0;
                TrainingCollection.Values.Shuffle();
                foreach (var trainingSet in TrainingCollection.Values)
                {
                    currentIterationCount++;
                    network.LearnSomething(trainingSet.Input, trainingSet.Response);
                }

                TrainingCollection.Values.Shuffle();
                errorForWholeEra = GiveErrorForWholeEra(network);
            }
            while(!Stop(errorForWholeEra, era, currentIterationCount));
        }
        /// <summary>
        /// Prepares the network.
        /// </summary>
        private void PrepareNetwork()
        {
            int[] neurons = new int[3];
            neurons[0] = WIDTH_FOR_BITMAP * HEIGHTH_FOR_BITMAP;
            neurons[1] = 88;
            neurons[2] = 10;
            double beta = 2.0;
            double eta = 0.2;
            double momentum = 0.3;

            _network = new TeachableNetwork(neurons, beta, eta, momentum);
            TrainingCollection trainingData = TrainingCollection.LoadUserData(_path);

            double minDelta = 0.001; // 0.005
            int maxAge = 1000;
            int maxIteration = 10000000;
            _teacherForNetwork = new Teacher(trainingData, minDelta, maxAge, maxIteration);
        }