public FPBinLeNetTest() { conv1 = new FPConv2d(1, 20, 5, 1, 0); pool1 = new MaxPool2d(2, 2); conv2 = new BinConv2d(20, 50, 5, 1, 0, fpBn: true); pool2 = new MaxPool2d(2, 2); //fc1 = new BinLinear(50 * 4 * 4, 500, false, true); fc1 = new FPBinLinear(50 * 4 * 4, 500, false); fc2 = new FPLinear(500, 10, true); bn1 = new FPBatchNorm2d(20); bn2 = new FPBatchNorm2d(50); bn3 = new FPBatchNorm1d(500); conv1.Name = "conv1"; pool1.Name = "pool1"; pool2.Name = "pool2"; conv2.Name = "conv2"; fc1.Name = "fc1"; fc2.Name = "fc2"; bn1.Name = "bn1"; bn2.Name = "bn2"; bn3.Name = "bn3"; items.Add(bn1); items.Add(bn2); items.Add(bn3); items.Add(fc2); items.Add(fc1); items.Add(conv1); items.Add(conv2); items.Add(pool1); items.Add(pool2); }
public void Redraw( ) { var img = input.Get2DImageFrom4DArray(0, 0); Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); var gr = Graphics.FromImage(bmp); gr.Clear(Color.White); int ww = int.Parse(textBox1.Text); for (int i = 0; i < img.Shape[0]; i++) { for (int j = 0; j < img.Shape[1]; j++) { gr.DrawRectangle(Pens.Black, j * ww, i * ww, ww, ww); gr.DrawString(Math.Round(img.Get2D(i, j), 3) + "", new Font("Consolas", 10), Brushes.Black, j * ww, i * ww); } } pictureBox1.Image = bmp; MaxPool2d pool = new MaxPool2d(2, 2); var res = pool.Forward(input); var img2 = res.Get2DImageFrom4DArray(0, 0); Bitmap bmp2 = new Bitmap(pictureBox2.Width, pictureBox2.Height); var gr2 = Graphics.FromImage(bmp2); gr2.Clear(Color.White); for (int i = 0; i < img2.Shape[0]; i++) { for (int j = 0; j < img2.Shape[1]; j++) { gr2.DrawRectangle(Pens.Black, j * ww, i * ww, ww, ww); gr2.DrawString(Math.Round(img2.Get2D(i, j), 3) + "", new Font("Consolas", 10), Brushes.Black, j * ww, i * ww); } } pictureBox2.Image = bmp2; }