Esempio n. 1
0
        public void ThresholdLayer_ForwardWithConfiguration()
        {
            var config = new ThresholdLayerConfiguration(0.5f);
            var layer  = new ThresholdLayer(config);

            layer.Setup(bottom, top);
            layer.Forward(bottom, top);

            Assert.Equal(bottom.Count, top.Count);

            using (var topCpu = top.OnCpu())
                using (var bottomCpu = bottom.OnCpu())
                {
                    int count = bottom.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Assert.True(topCpu.DataAt(i) >= 0.0d);
                        Assert.True(topCpu.DataAt(i) <= 1.0d);

                        if (topCpu.DataAt(i) == 0.0d)
                        {
                            Assert.True(bottomCpu.DataAt(i) <= layer.Parameters.Threshold);
                        }
                        else if (topCpu.DataAt(i) == 1.0d)
                        {
                            Assert.True(bottomCpu.DataAt(i) > layer.Parameters.Threshold);
                        }
                        else
                        {
                            Assert.True(false);
                        }
                    }
                    ;
                }
        }
        public void ThresholdLayer_ForwardWithConfiguration()
        {
            var config = new ThresholdLayerConfiguration(0.5f);
            var layer = new ThresholdLayer(config);
            layer.Setup(bottom, top);
            layer.Forward(bottom, top);

            Assert.Equal(bottom.Count, top.Count);

            using (var topCpu = top.OnCpu())
            using (var bottomCpu = bottom.OnCpu())
            {
                int count = bottom.Count;
                for (int i = 0; i < count; i++)
                {
                    Assert.True(topCpu.DataAt(i) >= 0.0d);
                    Assert.True(topCpu.DataAt(i) <= 1.0d);

                    if (topCpu.DataAt(i) == 0.0d)
                    {
                        Assert.True(bottomCpu.DataAt(i) <= layer.Parameters.Threshold);
                    }
                    else if (topCpu.DataAt(i) == 1.0d)
                    {
                        Assert.True(bottomCpu.DataAt(i) > layer.Parameters.Threshold);
                    }
                    else Assert.True(false);
                };
            }
        }
Esempio n. 3
0
        public void ThresholdLayer_Backward()
        {
            var layer = new ThresholdLayer();

            layer.Setup(bottom, top);
            Assert.Throws <NotSupportedException>(() => layer.Backward(top, new List <bool> {
                false
            }, bottom));
        }
Esempio n. 4
0
        public void ThresholdLayer_Setup()
        {
            var layer = new ThresholdLayer();

            layer.Setup(bottom, top);

            Assert.Equal(bottom.Num, top.Num);
            Assert.Equal(bottom.Channels, top.Channels);
            Assert.Equal(bottom.Height, top.Height);
            Assert.Equal(bottom.Width, top.Width);
        }
 public void ThresholdLayer_Backward()
 {
     var layer = new ThresholdLayer();
     layer.Setup(bottom, top);
     Assert.Throws<NotSupportedException>(() => layer.Backward(top, new List<bool> { false }, bottom));
 }
        public void ThresholdLayer_Setup()
        {
            var layer = new ThresholdLayer();
            layer.Setup(bottom, top);

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