private static Bitmap MakeBitmapFromMnist(MnistImage mnsIm, int coof)
        {
            Bitmap   bmI = new Bitmap(mnsIm.width * coof, mnsIm.height * coof);
            Graphics gr  = Graphics.FromImage(bmI);

            for (int i = 0; i < mnsIm.width; i++)
            {
                for (int j = 0; j < mnsIm.height; j++)
                {
                    int pixelColor          = 255 - mnsIm.pixels[i][j];
                    System.Drawing.Color c  = System.Drawing.Color.FromArgb(pixelColor, pixelColor, pixelColor);
                    SolidBrush           sb = new SolidBrush(c);
                    gr.FillRectangle(sb, j * coof, i * coof, coof, coof);
                }
            }

            return(bmI);
        }
        private static List <MnistImage> ReadMnistBase(string imageFilePath, string labelFilePath)
        {
            List <MnistImage> images = new List <MnistImage>();

            System.IO.FileStream   fsImage = new System.IO.FileStream(imageFilePath, System.IO.FileMode.Open);
            System.IO.FileStream   fsLabel = new System.IO.FileStream(labelFilePath, System.IO.FileMode.Open);
            System.IO.BinaryReader brImage = new System.IO.BinaryReader(fsImage);
            System.IO.BinaryReader brLabel = new System.IO.BinaryReader(fsLabel);

            int magic1     = ReverseByte(brImage.ReadInt32());
            int imageCount = ReverseByte(brImage.ReadInt32());
            int rowsCount  = ReverseByte(brImage.ReadInt32());
            int colsCount  = ReverseByte(brImage.ReadInt32());

            int magic2     = ReverseByte(brLabel.ReadInt32());
            int labesCount = ReverseByte(brLabel.ReadInt32());

            for (int n = 0; n < imageCount; n++)
            {
                List <List <byte> > bytes = new List <List <byte> >();
                for (int i = 0; i < rowsCount; i++)
                {
                    List <byte> col = new List <byte>();
                    for (int j = 0; j < colsCount; j++)
                    {
                        col.Add(brImage.ReadByte());
                    }
                    bytes.Add(col);
                }
                byte       label = brLabel.ReadByte();
                MnistImage img   = new MnistImage(rowsCount, colsCount, bytes, label);
                images.Add(img);
            }

            fsImage.Close();
            fsLabel.Close();
            brImage.Close();
            brLabel.Close();

            return(images);
        }
        private List <double> Recognize(MnistImage img)
        {
            List <double> kr    = new List <double>();
            List <double> input = new List <double>();

            for (int l = 0; l < img.height; l++)
            {
                for (int m = 0; m < img.width; m++)
                {
                    if (img.pixels[m][l] > 0)
                    {
                        input.Add(1);
                    }
                    else
                    {
                        input.Add(0);
                    }
                }
            }

            kr = wb.Res(input);

            return(kr);
        }