Пример #1
0
        public void ReluPrimeTest()
        {
            var a = new Matrix(2, 2);

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

            a = new Relu().Backward(a);
            b.InMap((x) => x > 0 ? 1 : 0);
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new Relu().Type().ToString() + " Derivative.");
        }
Пример #2
0
        public void ReluTest()
        {
            var a = new Matrix(2, 2);

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

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