Beispiel #1
0
        public void CalculatesActivationsWithActivator()
        {
            var activator = new Sigmoid();
            var last      = new Layer(3, null, activator);
            var first     = new Layer(2, last);

            last.Weights = Matrix.Build.DenseOfArray(new double[3, 2] {
                { 1, 2 },
                { 1.3, 0.1 },
                { 10, -5 },
            });

            last.Biases = Vec.Build.DenseOfArray(new double[] { 100, 200, 300 });

            var input              = Vec.Build.DenseOfArray(new double[] { 1, 10 });
            var expectedZ          = Vec.Build.DenseOfArray(new double[] { 121, 202.3, 260 });
            var expectedActivation = activator.Activate(expectedZ);

            var result = last.Activate(input);

            Assert.Equal(result, expectedActivation);
        }