예제 #1
0
        public BinLeNetTest()
        {
            conv1 = new Conv2d(1, 20, 5, 1, 0);
            pool1 = new MaxPool2d(2, 2);
            conv2 = new BinConv2d(20, 50, 5, 1, 0);
            pool2 = new MaxPool2d(2, 2);
            fc1   = new BinLinear(50 * 4 * 4, 500, false);
            fc2   = new Linear(500, 10, true);
            bn1   = new BatchNorm2d(20);
            bn2   = new BatchNorm2d(50);
            bn3   = new BatchNorm1d(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);
        }
예제 #2
0
        public BinConv2d(int inChannels, int outChannels, int kSize, int stride, int padding, bool bias = false, int dilation = 1, bool fpBn = false)
        {
            this.inChannels  = inChannels;
            this.outChannels = outChannels;
            Weight           = new InternalArray(new int[] { outChannels, inChannels, kSize, kSize });

            this.padding    = new int[] { padding, padding };
            this.stride     = new[] { stride, stride };
            this.kernelSize = new[] { kSize, kSize };
            this.dilation   = new[] { dilation, dilation };
            if (fpBn)
            {
                bn = new FPBatchNorm2d(inChannels);
            }
            else
            {
                bn = new BatchNorm2d(inChannels);
            }
        }