public void AveragePoolingLayer_Forward()
        {
            var bottom = new Tensor(1, 1, 3, 3);

            var filler = new ConstantFiller(2.0d);
            filler.Fill(bottom);

            var layer = new AveragePoolingLayer(3, 1, 1);
            layer.Setup(bottom, top);

            Assert.Equal(1, top.Num);
            Assert.Equal(1, top.Channels);
            Assert.Equal(3, top.Height);
            Assert.Equal(3, top.Width);

            layer.Forward(bottom, top);

            using (var topCpu = top.OnCpu())
            {
                var topData = topCpu.Data;
                AssertInRange(8.0d / 9, topData[0]);
                AssertInRange(4.0d / 3, topData[1]);
                AssertInRange(8.0d / 9, topData[2]);
                AssertInRange(4.0d / 3, topData[3]);
                AssertInRange(2.0d, topData[4]);
                AssertInRange(4.0d / 3, topData[5]);
                AssertInRange(8.0d / 9, topData[6]);
                AssertInRange(4.0d / 3, topData[7]);
                AssertInRange(8.0d / 9, topData[8]);
            }
        }
        public void AveragePoolingLayer_BackwardGradient( Size kernel, Size stride, Size padding )
        {
            var filler = new ConstantFiller(2.0d);
            filler.Fill(bottom);

            var checker = new GradientChecker(1e-2f, 1e-2f);

            var layer = new AveragePoolingLayer(kernel, stride, padding);
            checker.CheckExhaustive(layer, bottom, top);
        }
        public void AveragePoolingLayer_SetupPadded()
        {
            var layer = new AveragePoolingLayer(3, 2, 1);
            layer.Setup(bottom, top);

            Assert.Equal(bottom.Num, top.Num);
            Assert.Equal(bottom.Channels, top.Channels);
            Assert.Equal(4, top.Height);
            Assert.Equal(3, top.Width);
        }