Exemple #1
0
        public void EluTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var          b     = a.Duplicate();
            const double alpha = 0.01;

            a = new Elu(0.01).Forward(a);
            b.InMap((x) => x >= 0 ? x : alpha * (Math.Exp(x) - 1));
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new Elu(0.01).Type().ToString() + "ELU Activation.");
        }
Exemple #2
0
        public void EluPrimeTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var          b     = a.Duplicate();
            const double alpha = 0.01;

            a = new Elu(0.01).Backward(a);
            b.InMap((x) => x >= 0 ? 1 : alpha * Math.Exp(x));
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new Elu(0.01).Type().ToString() + " Derivative.");
        }