public void NN_backpropagation_generic_rprop_3L_gnb_all_training_samples()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(1, 2, .5, 1500);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.AddHiddenLayer(1, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Sigmoid());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < 10; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);

                if (SupportFunctions.DoubleCompare(value,
                                                   _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }
            //Due to random weights
            Assert.IsTrue(count >= 5);
        }
Ejemplo n.º 2
0
 public BuildGenericDeepNN()
 {
     _buildGenericRprop =
         new BuildGenericBackPropagationRprop();
     _buildGenericRprop.SetParameters(0, 2);
     NumberOfUnitsHiddenLayer = -1;
     _scalingFactor           = 2;
     _noOfHiddenLayers        = 2; //1 Output, 2 Hidden
 }
        public void NN_backpropagation_generic_rprop_invalid_layer_throws_exception()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(1, 1, .5, 1500);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.AddHiddenLayer(1, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Sigmoid());
        }
        public void NN_backpropagation_generic_rprop_one_hidden_pythagoras_rmse_data_1()
        {
            Init_dataset_pythagoras();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(0, 1, .02, 20000, .1);//,.005,2000);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Linear());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            /*
             * model.SetWeight(1, 0, 0, .53);
             * model.SetWeight(1, 1, 0, .53);
             * model.SetWeight(1, 2, 0, .53);
             *
             * model.SetWeight(1, 0, 1, .53);
             * model.SetWeight(1, 1, 1, .53);
             * model.SetWeight(1, 2, 1, .53);
             *
             * model.SetWeight(2, 0, 0, .53);
             * model.SetWeight(2, 1, 0, .53);
             * model.SetWeight(2, 2, 0, .53);
             */

            System.Diagnostics.Debug.WriteLine("Weight[1][0][0]:" + model.GetWeight(1, 0, 0));
            System.Diagnostics.Debug.WriteLine("Weight[1][1][0]:" + model.GetWeight(1, 1, 0));
            System.Diagnostics.Debug.WriteLine("Weight[1][2][0]:" + model.GetWeight(1, 2, 0));

            System.Diagnostics.Debug.WriteLine("Weight[1][0][1]:" + model.GetWeight(1, 0, 1));
            System.Diagnostics.Debug.WriteLine("Weight[1][1][1]:" + model.GetWeight(1, 1, 1));
            System.Diagnostics.Debug.WriteLine("Weight[1][2][1]:" + model.GetWeight(1, 2, 1));

            System.Diagnostics.Debug.WriteLine("Weight[2][0][1]:" + model.GetWeight(2, 0, 0));
            System.Diagnostics.Debug.WriteLine("Weight[2][1][1]:" + model.GetWeight(2, 1, 0));
            System.Diagnostics.Debug.WriteLine("Weight[2][2][1]:" + model.GetWeight(2, 2, 0));

            int row = 0;

            double[] data  = GetSingleTrainingRowDataForTest(row);
            double   value = model.RunModelForSingleData(data);

            Assert.IsTrue(value <= 1.69);
        }
        public void NN_backpropagation_generic_rprop_missing_layer_throws_exception()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(1, 3, .5, 1500);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.AddHiddenLayer(1, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Sigmoid());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);
        }
        public void NN_backpropagation_generic_rprop_no_hidden_pythagoras_rmse()
        {
            Init_dataset_pythagoras();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(0, 0, .3, 1);
            build.SetOutputLayerActivationFunction(new Linear());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            double value = model.GetModelRMSE(_trainingData);

            Assert.IsTrue(value < 10);
        }
        public void NN_backpropagation_generic_rprop_jason_simple_rmse()
        {
            Init_dataset_jason_linear_regression();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(0, 1, .01, 10000);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Linear());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            double value = model.GetModelRMSE(_trainingData);

            Assert.IsTrue(value < .61 && value > 0);
        }
        public void NN_backpropagation_generic_rprop_gnb_single_training_sample_class_0()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildGenericBackPropagationRprop build =
                new BuildGenericBackPropagationRprop();

            build.SetParameters(1, 1);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Sigmoid());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase )build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int row = 0;

            double[] data  = GetSingleTrainingRowDataForTest(row);
            double   value = model.RunModelForSingleData(data);

            Assert.AreEqual(value,
                            _trainingData[_indexTargetAttribute][row]);
        }