Example #1
0
        private void buttonLoadNetwork_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "All Files (*.*)|*.*";
            openFileDialog.FilterIndex = 1;
            openFileDialog.Multiselect = false;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                mlpNetwork = new MLPNetwork();
                try
                {
                    mlpNetwork.LoadNetwork(openFileDialog.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    mlpNetwork = null;
                }
            }
        }
Example #2
0
        private void buttonTrain_Click(object sender, EventArgs e)
        {
            if (numericUpDownLayersCount.Value == 0 || numericUpDownNeuronsCount.Value == 0 || numericUpDownIterationsCount.Value == 0 || comboBoxActivationFunction.Text == string.Empty || comboBoxProblemType.Text == string.Empty)
            {
                MessageBox.Show("Brak zdefiniowanych wartości pól lub niedozwolone wartości pól.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if(inputDataFileName == string.Empty)
            {
                MessageBox.Show("Brak danych treningowych.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int layersCount = Decimal.ToInt32(numericUpDownLayersCount.Value);
            int neuronsCount = Decimal.ToInt32(numericUpDownNeuronsCount.Value);
            int iterationsCount = Decimal.ToInt32(numericUpDownIterationsCount.Value);
            double learningRate = Decimal.ToDouble(numericUpDownLearningRate.Value);
            double momentum = Decimal.ToDouble(numericUpDownMomentum.Value);

            mlpNetwork = new MLPNetwork(layersCount, neuronsCount, checkBoxBias.Checked,comboBoxActivationFunction.Text == "bipolarna" ? ActivationFunctionType.Bipolar : ActivationFunctionType.Unipolar, comboBoxProblemType.Text == "klasyfikacja" ? ProblemType.Classification : ProblemType.Regression, inputDataFileName );

            double[][] errors = mlpNetwork.Train(iterationsCount, learningRate, momentum);

            chartErrors.Series["Błędy test."].Points.Clear();
            chartErrors.Series["Błędy walid."].Points.Clear();

            for (int i = 0; i < errors[0].Length; i++)
            {
                chartErrors.Series["Błędy test."].Points.AddXY(i + 1, errors[0][i]);
                chartErrors.Series["Błędy walid."].Points.AddXY(i + 1, errors[1][i]);
            }

            mlpNetwork.SaveNetwork("network");
        }