Пример #1
0
        public void TestAlternativeMatrix()
        {
            double[][] from_l1 = new double[][]
            {
                new double[] { -30, 20, 20 },
                new double[] { 10, -20, -20 }
            };
            double[][] from_l2 = new double[][]
            {
                new double[] { -10, 20, 20 }
            };
            double[][][] weights = new double[][][]
            {
                from_l1,
                from_l2
            };
            NNetwork n = NNetwork.SigmoidNetwork(new int[] { 2, 2, 1 });

            n.SetWeightMatrix(weights);

            double[]   from_l1_expected = new double[] { -30, 20, 20, 10, -20, -20 };
            double[]   from_l2_expected = new double[] { -10, 20, 20 };
            double[][] weights_expected = new double[][]
            {
                from_l1_expected,
                from_l2_expected
            };
            Assert.AreEqual(weights_expected, n.GetWeightMatrix());
        }
Пример #2
0
        public void TestInputEqualsOutput()
        {
            NNetwork n = NNetwork.SigmoidNetwork(new int[] { 1 });

            n.SetWeightMatrix(new double[][]
            {
                new double[] { 1, 1 }
            });
            n.SetInput(new double[] { 9 });
            Assert.AreEqual(n.GetOutput()[0], 9);
        }
Пример #3
0
        public void TestWeightMatrix()
        {
            double[]   from_l1 = new double[] { -30, 20, 20, 10, -20, -20 };
            double[]   from_l2 = new double[] { -10, 20, 20 };
            double[][] weights = new double[][]
            {
                from_l1,
                from_l2
            };
            NNetwork n = NNetwork.SigmoidNetwork(new int[] { 2, 2, 1 });

            n.SetWeightMatrix(weights);
            Assert.AreEqual(n.GetWeightMatrix(), weights);
        }
Пример #4
0
        public static NNetwork XorNetwork()
        {
            double[]   from_l1 = new double[] { -30, 20, 20, 10, -20, -20 };
            double[]   from_l2 = new double[] { -10, 20, 20 };
            double[][] weights = new double[][]
            {
                from_l1,
                from_l2
            };
            NNetwork xor_network = NNetwork.SigmoidNetwork(new int[] { 2, 2, 1 });

            xor_network.SetWeightMatrix(weights);
            return(xor_network);
        }
Пример #5
0
        public void TestSimplestConnection()
        {
            NNetwork n = NNetwork.SigmoidNetwork(new int[] { 1, 1 });

            n.SetWeightMatrix(new double[][]
            {
                new double[] { 1, 1 },
                new double[] { 1, 1 }
            });
            n.SetInput(new double[] { 1 });
            var output  = n.GetOutput()[0];
            var desired = 1 / (1 + Math.Pow(Math.E, -2));

            MyAssert.CloseTo(output, desired);
        }