public static int[,] guessAll(double[][]weights, BackgroundWorker bw, int optionsCount, int vectorLength, getVector gv)
 {
     int progress, maxProgress;
     progress = 0;
     int[] count = new int[optionsCount];
     Bitmap bmp;
     List<double> arr;
     int ID;
     int[,] result = new int[optionsCount, 2];
     string[] picturePaths = Directory.GetFiles(pathDigitsAndLetters);
     maxProgress = picturePaths.Length;
     //foreach (string picturePath in picturePaths)
     for(int j=0;j<picturePaths.Length;j++)
         {
             string picturePath = picturePaths[j];
             progress++;
             bw.ReportProgress((int)((float)progress / maxProgress * 100));
             bmp = new Bitmap(picturePath);
             int correctAnswer = getCorrectAnswer(picturePath);
             bmp = BmpProcesser.normalizeBitmap(bmp, 100, 100);
             arr = guess(gv(bmp), optionsCount, weights);
             ID = arr.IndexOf(arr.Min());
             if (ID == correctAnswer)
                 result[correctAnswer, 0]++;
             else
                 result[ID, 1]++;
         }
     return result;
 }
        public static double[][] learnAll(int learningCount, BackgroundWorker bw, bool linearDelta, double deltaAtTheEnd, int optionsCount, int vectorLength,getVector gv)
        {
            double delta = 1;
            double[][] weights;
            weights = new double[optionsCount][];
            for (int n = 0; n < optionsCount; n++)
            {
                weights[n] = new double[vectorLength];
                for (int i = 0; i < vectorLength; i++)
                    weights[n][i] = 0;
            }
            int progress, maxProgress;
            Bitmap bmp;
            string[] picturePaths = Directory.GetFiles(pathDigitsAndLetters);
            Random rand = new Random();

            progress = 0;
            maxProgress = learningCount;
            for (int n = 0; n < learningCount; n++)
            {
                string picturePath = picturePaths[rand.Next(picturePaths.Length)];
                progress++;
                bw.ReportProgress((int)((float)progress / maxProgress * 100));
                bmp = new Bitmap(picturePath);
                bmp = BmpProcesser.normalizeBitmap(bmp, 100, 100);
                learnKohonen(gv(bmp), getCorrectAnswer(picturePath), weights, optionsCount, delta);

                if (deltaAtTheEnd >= 1)
                    deltaAtTheEnd = 0.99;
                if (linearDelta)
                {
                    delta = -(double)progress / ((1 / (1 - deltaAtTheEnd)) * maxProgress) + 1;
                }
                else
                {
                    if (deltaAtTheEnd <= 0)
                        deltaAtTheEnd = 0.01;
                    double a = deltaAtTheEnd / (1 - deltaAtTheEnd);
                    delta = a * learningCount / ((double)progress + a * learningCount);
                }
            }
            return weights;
        }
        public static double[][] learnAllAverage(int learningCount, BackgroundWorker bw, int optionsCount, int vectorLength, getVector gv)
        {
            double[][] weights = new double[optionsCount][];
            for (int n = 0; n < optionsCount; n++)
            {
                weights[n] = new double[vectorLength];
                for (int i = 0; i < vectorLength; i++)
                    weights[n][i] = 0;
            }

            int progress, maxProgress;
            double[] vector1 = new double[vectorLength];
            int[] count = new int[optionsCount];
            Bitmap bmp;

            string[] picturePaths = Directory.GetFiles(pathDigitsAndLetters);
            Random rand = new Random();

            progress = 0;
            maxProgress = learningCount;
            for (int n = 0; n < learningCount; n++)
            {
                string picturePath = picturePaths[rand.Next(picturePaths.Length)];
                int k = getCorrectAnswer(picturePath);
                progress++;
                bw.ReportProgress((int)((float)progress / maxProgress * 100));
                bmp = new Bitmap(100, 100);
                bmp = new Bitmap(picturePath);
                bmp = BmpProcesser.normalizeBitmap(bmp, 100, 100);
                vector1 = gv(bmp);
                for (int i = 0; i < vectorLength; i++)
                    weights[k][i] += vector1[i];
                count[k]++;
            }
            for (int k = 0; k < optionsCount; k++)
                for (int i = 0; i < vectorLength; i++)
                    weights[k][i] = weights[k][i] / count[k];
            return weights;
        }