示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            double dou = 0;

            listBox1.Items.Clear();
            for (int i = 0; i < 10; i++)
            {
                //Коэффициент обучение сети
                n = Convert.ToDouble(textBox_n.Text);

                //Объем обучающей выборки
                countRow  = Convert.ToInt32(textBox_X.Text);
                numHidden = Convert.ToInt32(textBox_C.Text);
                countIter = Convert.ToInt32(textBox1.Text);
                // чтение входных данных
                x = ReaderWriter.ReadMatrix(filename, countRow, numInput);
                double[] d = ReaderWriter.ReadVector(filename, countRow, numInput);
                D = new double[countRow, numOutput];
                RecD(d);

                //Инициализация центроид
                centroids = ReaderWriter.ReadMatrixC(filename, countRow, numInput, numHidden, d);

                rn           = new RBFNetwork(countRow, numInput, numHidden, numOutput, x, centroids, n, temp, er);
                rn.countIter = countIter;
                //Инициализация весов
                rn.SetWeight();

                // Обучение сети
                rn.TrainNetwork(x, centroids, countRow, numInput, numHidden, numOutput, D);

                er = rn.errTrain;


                countRow = 30;
                // чтение входных данных
                x = ReaderWriter.ReadMatrix("iris_test.txt", countRow, numInput);
                d = ReaderWriter.ReadVector("iris_test.txt", countRow, numInput);
                D = new double[countRow, numOutput];
                RecD(d);

                // Тестирование сети
                errTest = rn.TestNetwork(x, D, countRow, numInput, numOutput, numHidden);
                dou    += errTest;
                listBox1.Items.Add(errTest);
            }
            listBox1.Items.Add("Result: " + dou / 10);
        }
示例#2
0
        private void button_Sample_Click(object sender, EventArgs e)
        {
            label_err.Text = "Learning error: ";

            label_Test.Text = "Testing error: ";


            n = Convert.ToDouble(textBox_n.Text);

            //Объем обучающей выборки
            countRow  = Convert.ToInt32(textBox_X.Text);
            numHidden = Convert.ToInt32(textBox_C.Text);
            countIter = Convert.ToInt32(textBox1.Text);

            x = ReaderWriter.ReadMatrix(filename, countRow, numInput);
            double[] d = ReaderWriter.ReadVector(filename, countRow, numInput);
            D = new double[countRow, numOutput];
            RecD(d);

            //Ин центроид
            centroids = ReaderWriter.ReadMatrixC(filename, countRow, numInput, numHidden, d);
            Console.WriteLine(centroids);
            rn = new RBFNetwork(countRow, numInput, numHidden, numOutput, x, centroids, n, temp, er);
            // Console.WriteLine(rn);
            rn.countIter = countIter;
            //Ин весов
            rn.SetWeight();

            rn.TrainNetwork(x, centroids, countRow, numInput, numHidden, numOutput, D);
            // Console.WriteLine(rn);
            er             = rn.errTrain;
            label_err.Text = "Learning error: " + er;
            temp           = rn.temp;


            //  button_Sample.Enabled = false;
            button_test.Enabled = true;
        }