Exemplo n.º 1
0
        public void Test_GlobalAvgPool2D_Null_Input()
        {
            Data2D data = null;
            GlobalAvgPool2DLayer pool = new GlobalAvgPool2DLayer();

            pool.SetInput(data);
        }
Exemplo n.º 2
0
        public void Test_GlobalAvgPool2D_DifferentData_Input()
        {
            DataArray            data = new DataArray(5);
            GlobalAvgPool2DLayer pool = new GlobalAvgPool2DLayer();

            pool.SetInput(data);
        }
Exemplo n.º 3
0
        public void Test_GlobalAvgPool2D_Execute()
        {
            // Initialize data.
            Data2D data = new Data2D(3, 3, 2, 1);

            data[0, 0, 0, 0] = 1;
            data[1, 0, 0, 0] = 2;
            data[2, 0, 0, 0] = 0;

            data[0, 1, 0, 0] = 3;
            data[1, 1, 0, 0] = 4;
            data[2, 1, 0, 0] = 0;

            data[0, 2, 0, 0] = 2;
            data[1, 2, 0, 0] = 2;
            data[2, 2, 0, 0] = 0;


            data[0, 0, 1, 0] = 0;
            data[1, 0, 1, 0] = 3;
            data[2, 0, 1, 0] = 1;

            data[0, 1, 1, 0] = 1;
            data[1, 1, 1, 0] = 1;
            data[2, 1, 1, 0] = -1;

            data[0, 2, 1, 0] = -3;
            data[1, 2, 1, 0] = -1;
            data[2, 2, 1, 0] = 0;

            GlobalAvgPool2DLayer pool = new GlobalAvgPool2DLayer();

            pool.SetInput(data);
            pool.Execute();
            Data2D output = pool.GetOutput() as Data2D;

            // Checking sizes
            Dimension dim = output.GetDimension();

            Assert.AreEqual(dim.b, 1);
            Assert.AreEqual(dim.c, 2);
            Assert.AreEqual(dim.h, 1);
            Assert.AreEqual(dim.w, 1);

            // Checking calculation
            Assert.AreEqual(output[0, 0, 0, 0], 14.0 / 9.0, 0.0000001);
            Assert.AreEqual(output[0, 0, 1, 0], 1.0 / 9.0, 0.0000001);
        }