示例#1
0
        public AddChangeNeuroNetDialog(DataBaseHandler _dbHandler, NeuroNetDefinition neuro_def = null)
        {
            InitializeComponent();

            if (neuro_def == null)
                mode = form_destination.Creating;
            else
            {
                mode = form_destination.Editing;
                definition_of_editing_net = neuro_def;
            }

            dbHandler = _dbHandler;

            List<string> ls = dbHandler.SelectTasks();
            foreach (string par in ls)
            {
                cbTask.Items.Add(par);
            }

            ls = LibraryOfTopologies.GetAllTopologyTypeNames();
            foreach (string item in ls)
            {
                cbTopology.Items.Add(item);
            }

            string[] namesAF = LibraryOfActivateFunctions.GetAllActivateFunctionNames();
            for (int i = 0; i < LibraryOfActivateFunctions.GetCountActivateFunctions(); i++)
            {
                cbActivateFunction.Items.Add(namesAF[i]);
            }

            ls = dbHandler.SelectCountParametersInTasks();
            countInputParamsInTask = new int[ls.Count];
            for (int i = 0; i < ls.Count; i++)
            {
                countInputParamsInTask[i] = Convert.ToInt32(ls[i]);
            }

            dgwEditNeuronsInLayers.ColumnHeadersDefaultCellStyle.Font = new Font("Book Antiqua", 9);
            dgwEditNeuronsInLayers.Columns.Add("Layer", "Слой");
            dgwEditNeuronsInLayers.Columns.Add("Neurons", "Число нейронов");
            RefreshDgwNeuronsInLayers();

            dgwEditParametersAF.ColumnHeadersDefaultCellStyle.Font = new Font("Book Antiqua", 9);
            dgwEditParametersAF.Columns.Add("Parameter", "Параметр");
            dgwEditParametersAF.Columns.Add("Value", "Значение");

            switch (mode)
            {
                case form_destination.Creating:
                    Text = "Создание нейронной сети";
                    break;
                case form_destination.Editing:
                    Text = "Изменение Нейронной Сети";
                    tbNameNeuroNet.Text = definition_of_editing_net.Name;
                    for (int i = 0; i < cbTask.Items.Count; i++)
                    {
                        if (String.Compare(cbTask.Items[i].ToString(), definition_of_editing_net.TaskName) == 0)
                        {
                            cbTask.SelectedIndex = i;
                            break;
                        }
                    }
                    for (int i = 0; i < cbTopology.Items.Count; i++)
                    {
                        if (String.Compare(cbTopology.Items[i].ToString(), definition_of_editing_net.TopologyName) == 0)
                        {
                            cbTopology.SelectedIndex = i;
                            break;
                        }
                    }
                    if (cbTopology.SelectedIndex == -1)
                    {
                        MessageBox.Show("Топология, примененная в данной нейронной сети, " +
                        "не найдена. Она будет недоступна при изменении сети.");
                    }

                    numNeuronsNumber.Value = definition_of_editing_net.NeuronsCount;
                    numLayersNumber.Value = definition_of_editing_net.LayerCount;

                    for (int i = 0; i < definition_of_editing_net.LayerCount; i++)
                    {
                        dgwEditNeuronsInLayers.Rows[i].Cells[1].Value = definition_of_editing_net.NeuronsInLayer[i];
                    }

                    for (int i = 0; i < cbActivateFunction.Items.Count; i++)
                    {
                        if (String.Compare(cbActivateFunction.Items[i].ToString(), definition_of_editing_net.ActivateFunction) == 0)
                        {
                            cbActivateFunction.SelectedIndex = i;
                            break;
                        }
                    }

                    for (int i = 0; i < definition_of_editing_net.AFParameters.Length; i++)
                    {
                        dgwEditParametersAF.Rows[i].Cells[1].Value = definition_of_editing_net.AFParameters[i];
                    }
                    break;
            }
        }
示例#2
0
        private void btnChangeNeuroNet_Click(object sender, EventArgs e)
        {
            string[] line = dbHandler.SelectNeuroNetDefinitionByName(dgwNeuroNets.SelectedRows[0].Cells[0].Value.ToString());

            NeuroNetDefinition ndef = new NeuroNetDefinition(line);
            AddChangeNeuroNetDialog dialog = new AddChangeNeuroNetDialog(dbHandler, ndef);
            dialog.ShowDialog();
            LoadInformationForUsingNeuroNets();
            FillNeuroNetChangingTable();
            btnChangeNeuroNet.Enabled = false;
            btnDeleteNeuroNet.Enabled = false;

            dgwNeuronsInLayers.Rows.Clear();
            dgwParamsAF.Rows.Clear();
        }