Ejemplo n.º 1
0
        private void onClickTrainingButton(object sender, EventArgs e)
        {
            numOfEpochs = int.Parse(txtEpochs.Text);

            Eta = double.Parse(txtbxEta.Text);

            if (MLPFlag)
            {
                for (int i = 0; i < numOfHiddenLayers; i++)
                {
                    lstNeuronsPerEachHiddenLayer.Add(int.Parse(grvNumOfNeuronsPerEachLayers.Rows[i].Cells[0].Value.ToString()));
                }
                //no Read Data From the Saved File
                tryM = new MLP(Eta, numOfEpochs, chbxBias.Checked, lstNeuronsPerEachHiddenLayer, false);
                tryM.TrainingData();
            }
            else if (RBFFlag)
            {
                numOfClusters  = int.Parse(txtCenters.Text);
                KmeanThreshold = double.Parse(txtKmeanThreshold.Text);
                MseThreshold   = double.Parse(txtMseThreshold.Text);

                RadialBF = new RBF(numOfClusters, KmeanThreshold);
                RadialBF.Kmean();
                RadialBF.calculateVariance();
                RadialBF.TransformedInputGaussian();
                //no Read Data From the Saved File
                LeastMS = new LMS(Eta, numOfEpochs, MseThreshold, chbxBias.Checked, numOfClusters, RadialBF, false);
                LeastMS.TrainingData();
            }
        }
Ejemplo n.º 2
0
        private void btnTestOneSample_Click(object sender, EventArgs e)
        {
            #region OpenDialog
            openFileDialog1.ShowDialog();
            string fn = openFileDialog1.FileName;
            Bitmap B  = PGMUtil.ToBitmap(fn);
            pictureBox1.Image = (Image)B;
            int s = fn.LastIndexOf('\\') + 1;
            #endregion
            if (txtEpochs.Text == "")
            {
                if (RBFFlag)
                {
                    RadialBF = new RBF();
                    LeastMS  = new LMS(Eta, numOfEpochs, MseThreshold, chbxBias.Checked, numOfClusters, RadialBF, true);
                }
                else
                {
                    tryM = new MLP(Eta, numOfEpochs, chbxBias.Checked, new List <int> {
                        4, 4, 4
                    }, true);
                }
                lblAccuracy.Text = "65";
            }

            if (RBFFlag)
            {
                LeastMS.get_sample_test_info(fn.Substring(s).Replace(".pgm", ".pts"));
                lblActualResult.Text = LeastMS.TestingOnePicture();
            }
            else
            {
                tryM.get_sample_test_info(fn.Substring(s).Replace(".pgm", ".pts"));
                lblActualResult.Text = tryM.Testing_Data_Sample();
            }
        }
        public LMS(double pEta , int pEpochs,double pmse_th, bool pBias,int input_num,RBF Obj,bool read_from_file)
        {
            p = new Process();
            RbfObj = Obj;
            RandomList=new List<int>();
            InputNumRBF = input_num;
            desiredOutput_D=new int [OutPutNodes];
            actualOutput_Y = new double[OutPutNodes];
            weights = new double[OutPutNodes, InputNumRBF];
            TempWeights = new double[OutPutNodes, InputNumRBF];
            ErrorForStoreWeights = 100000;
            sum_mean = 0;
            Error_E = new double[OutPutNodes];
            TotalFatalError = new double[OutPutNodes];
            netValue_V = 0;
            mse_threshold = pmse_th;
            eta = pEta;
            checkBias = pBias;
            epochs = pEpochs;

            bias = new double[OutPutNodes];
            TempBias = new double[OutPutNodes];

            if (read_from_file)
                Read_weights_from_file();
            else
            {
                Generate_Random_Weights();
                GaussianData = Obj.gauss;//Trianing and Testing data
            }

            confusionMatrix = new int[OutPutNodes, OutPutNodes];
            for (int i = 0; i < OutPutNodes; i++)
             for (int j = 0; j < OutPutNodes; j++)
                  confusionMatrix[i,j]=0;
        }