コード例 #1
0
        public void TestRandomInit()
        {
            NNetwork n = NNetwork.SigmoidNetwork(new int[] { 2, 3, 2 });

            n.RandomizeWeights(seed: 0);
            var first = n.GetWeightMatrix();

            n.RandomizeWeights(seed: 0);
            var equal = n.GetWeightMatrix();

            Assert.AreEqual(first, equal);
            n.RandomizeWeights(seed: 1);
            var not_equal = n.GetWeightMatrix();

            Assert.AreNotEqual(first, not_equal);
        }
コード例 #2
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());
        }
コード例 #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);
        }