public void NN_backpropagation_generic_std_one_hidden_pythagoras_single_data_0() { Init_dataset_pythagoras(); BuildGenericBackPropagationStandard build = new BuildGenericBackPropagationStandard(); build.SetParameters(0, 1, .001, 2500, .001); //build.SetNumberOfHiddenLayers(1); build.AddHiddenLayer(0, 2, new Sigmoid()); build.SetOutputLayerActivationFunction(new Linear()); ModelBackPropagationBase model = (ModelBackPropagationBase)build.BuildModel( _trainingData, _attributeHeaders, _indexTargetAttribute); /* * model.SetWeight(1, 0, 0, .2196); * model.SetWeight(1, 1, 0, .121); * model.SetWeight(1, 2, 0, -4.18); * * model.SetWeight(1, 0, 1, .15367); * model.SetWeight(1, 1, 1, .2216); * model.SetWeight(1, 2, 1, -.99404); * * model.SetWeight(2, 0, 0, 15.43); * model.SetWeight(2, 1, 0, 12.92); * model.SetWeight(2, 2, 0, -3.33);*/ 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); System.Diagnostics.Debug.WriteLine("Final value:" + value); //Actual answer is 1.41 Assert.IsTrue(value > 1.0 && value < 3.0); }
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); }