Accord.Tests.Neuro.LevenbergMarquardtLearningTest.RunEpochTest3 C# (CSharp) Method

RunEpochTest3() private method

private RunEpochTest3 ( ) : void
return void
        public void RunEpochTest3()
        {
            double[,] dataset = yinyang;

            double[][] input = dataset.GetColumns(new[] { 0, 1 }).ToJagged();
            double[][] output = dataset.GetColumn(2).ToJagged();

            // Neuron.RandGenerator = new ThreadSafeRandom(0);
            Accord.Math.Random.Generator.Seed = 0;

            ActivationNetwork network = new ActivationNetwork(
                   new BipolarSigmoidFunction(2), 2, 5, 1);

            var teacher = new LevenbergMarquardtLearning(network,
                true, JacobianMethod.ByBackpropagation);

            Assert.IsTrue(teacher.UseRegularization);

            double error = 1.0;
            for (int i = 0; i < 500; i++)
                error = teacher.RunEpoch(input, output);

            double[][] actual = new double[output.Length][];

            for (int i = 0; i < input.Length; i++)
                actual[i] = network.Compute(input[i]);

            for (int i = 0; i < input.Length; i++)
                Assert.AreEqual(Math.Sign(output[i][0]), Math.Sign(actual[i][0]));
        }