Exemplo n.º 1
0
        public NeuroticOneForm()
        {
            InitializeComponent();
            currentNetworkType = NeuroticProgramType.NeuroticProgramTypeFeedForward;
            currentActivationFunctionType = NeuroticActivationFunctionType.NeuroticActivationFunctionTypeUnipolar;
            inputValues = outputValues = 1;
            numberOfCycles = 100;
            BlockInterface(false);

            //this.parametersFileDialog.InitialDirectory = Path.Combine(Application.ExecutablePath, "Files");
            string current = System.IO.Directory.GetCurrentDirectory();

            current=  Directory.GetParent(Directory.GetParent(Directory.GetParent(current).FullName).FullName).FullName;//System.IO.Path.GetDirectoryName(Application.ExecutablePath);
            current = Path.Combine(current, "Files");
            this.parametersFileDialog.InitialDirectory = current;
            this.parametersFileDialog.FileName = "settings.txt";
            this.testFileDialog.InitialDirectory = current;
            this.testFileDialog.FileName = "test.txt";
            this.learningFileDialog.InitialDirectory = current;
            this.learningFileDialog.FileName = "teachunipolar.txt";
            UpdateLabels();
        }
Exemplo n.º 2
0
        private void SwitchInterface(NeuroticProgramType type)
        {
            bool value = type == NeuroticProgramType.NeuroticProgramTypeFeedForward;
            //this.layersNumberTextBox.Enabled = value;
            this.inputNumberTextBox.Enabled = value;
            this.outputNumberTextBox.Enabled = value;
            this.neuronNumberTextBox.Enabled = !value;
            this.inputSizeTextBox.Enabled = !value;

            if (value)
            {
                this.neuronNumberTextBox.Text = "";
                this.inputSizeTextBox.Text = "";
            }
            else
            {
                this.layersNumberTextBox.Text = "";
                this.inputNumberTextBox.Text = "";
                this.outputNumberTextBox.Text = "";
            }
        }
Exemplo n.º 3
0
        private void parametersButton_Click(object sender, EventArgs e)
        {
            if (parametersFileDialog.ShowDialog() == DialogResult.OK)
            {
                StreamReader reader = null;
                    try
                    {
                        reader = File.OpenText(parametersFileDialog.FileName);
                        string str = null;
                        int i = 0;

                        str = reader.ReadLine();
                        str = (str.Split(' '))[0];
                        if (String.Compare(str, "feedforward", true) == 0)
                        {
                            this.currentNetworkType = NeuroticProgramType.NeuroticProgramTypeFeedForward;
                            this.feedForwardRadioButton.Select();

                            str = reader.ReadLine();
                            string[] strs = str.Split(' ');
                            if (String.Compare(strs[0], "bias", true) == 0)
                            {
                                bias = true;
                            }
                            else if (String.Compare(strs[0], "nobias", true) == 0)
                            {
                                bias = false;
                            }

                            if (String.Compare(strs[1], "unipolar", true) == 0)
                            {
                                this.unipolarRadioButton.Select();
                            }
                            else if (String.Compare(strs[1], "bipolar", true) == 0)
                            {
                                this.biPolarRadioButton.Select();
                            }

                            str = reader.ReadLine();
                            str = str.Replace('.',',');
                            int index = str.IndexOf("/*");
                            if (index != -1) str = str.Substring(0, index);
                            char[] chars = { ' ' };
                            strs = str.Split(chars, StringSplitOptions.RemoveEmptyEntries);
                            int hiddenCount = strs.Length-2;
                            hiddenLayer = new int[hiddenCount];
                            WriteLine(hiddenCount.ToString());
                            this.inputValues = int.Parse(strs[0]);
                            this.outputValues = int.Parse(strs[strs.Length - 1]);
                            for (int q = 1; q < strs.Length - 1; ++q)
                            {
                                hiddenLayer[q - 1] = int.Parse(strs[q]);
                            }

                            str = reader.ReadLine();
                            str = str.Replace('.', ',');
                            index = str.IndexOf("/*");
                            if (index != -1) str = str.Substring(0, index);
                            strs = str.Split(chars, StringSplitOptions.RemoveEmptyEntries);

                            this.numberOfCycles = int.Parse(strs[0]);
                            this.learningRate = double.Parse(strs[1]);
                            this.momentum = double.Parse(strs[2]);

                            parametersLoaded = true;

                            UpdateLabels();

                        }
                        else if (String.Compare(str, "kohonen", true) == 0)
                        {
                            this.currentNetworkType = NeuroticProgramType.NeuroticProgramTypeKohonen;
                            this.kohonenRadioButton.Select();

                            String[] line2 = reader.ReadLine().Split(' ');
                            String[] line3 = reader.ReadLine().Split(' ');

                            liczba_wejsc = Int32.Parse(line2[0]);
                            liczba_neuronow_poziom = Int32.Parse(line2[1]);
                            liczba_neuronow_pion = Int32.Parse(line2[2]);

                            numberOfCycles = Int32.Parse(line3[0]);
                            pocz_rozmiar_sasiedz = Int32.Parse(line3[1]);
                            wsp_zmian_rozm_sasiedz = Double.Parse(line3[2], CultureInfo.InvariantCulture);
                            pocz_wart_wsp_nauki = Double.Parse(line3[3], CultureInfo.InvariantCulture);
                            wps_zmiany_wsp = Double.Parse(line3[4], CultureInfo.InvariantCulture);

                            UpdateLabels();
                            parametersLoaded = true;
                        }

                    }
                    catch (Exception c)
                    {
                        Console.WriteLine(c.Message);
                        MessageBox.Show("Failed reading the file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    finally
                    {
                        // close file
                        if (reader != null)
                            reader.Close();
                    }
            }
            teachingDone = false;
            UpdateLabels();
        }