Ejemplo n.º 1
0
        //Shuffles the Dataset (used to have random data samples)
        public static void Shuffle(List <MNISTReader.DigitImage> list)
        {
            Random rng = new Random();
            int    n   = list.Count;

            while (n > 1)
            {
                n--;
                int k = rng.Next(n + 1);
                MNISTReader.DigitImage value = list[k];
                list[k] = list[n];
                list[n] = value;
            }
        }
Ejemplo n.º 2
0
        //MNIST to vector converter
        public static Vector ConvertImageToVector(MNISTReader.DigitImage image)
        {
            Vector doublevector = new Vector(28 * 28);
            int    count        = 0;

            for (int i = 0; i < 28; i++)
            {
                for (int j = 0; j < 28; j++)
                {
                    if (image.pixels[i][j] != 0)
                    {
                        doublevector.data[count] = image.pixels[i][j] / 256.0;
                    }

                    count++;
                }
            }
            return(doublevector);
        }