예제 #1
0
        public void HardSigmoidPrimeTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var b = a.Duplicate();

            a = new HardSigmoid().Backward(a);
            b.InMap((x) => x > 1 || x < 0 ? 0 : 1);
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new HardSigmoid().Type().ToString() + "  Derivative.");
        }
예제 #2
0
        public void HardSigmoidTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var b = a.Duplicate();

            a = new HardSigmoid().Forward(a);
            b.InMap((x) => x < 0 ? 0 : x < 1 ? x : 1);
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new HardSigmoid().Type().ToString() + "  Activation.");
        }