Ejemplo n.º 1
0
        private void configSubmitButton_Click(object sender, EventArgs e)
        {
            if (!(RegularExpression.DoubleCheck(momentumTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(momentumTextBox.Text)))
            {
                MessageBox.Show("Momentum is worng. Check Please.");
                momentumTextBox.Focus();
                momentumTextBox.SelectAll();
            }
            else if (!(RegularExpression.DoubleCheck(activationCriterionTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(activationCriterionTextBox.Text)))
            {
                MessageBox.Show("Activation Criterion is worng. Check Please.");
                activationCriterionTextBox.Focus();
                activationCriterionTextBox.SelectAll();
            }
            else if (!(RegularExpression.DoubleCheck(inactivationCriterionTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(inactivationCriterionTextBox.Text)))
            {
                MessageBox.Show("Inactivation Criterion is worng. Check Please.");
                inactivationCriterionTextBox.Focus();
                inactivationCriterionTextBox.SelectAll();
            }
            else if (!(RegularExpression.DoubleCheck(initialWeightRangeTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(initialWeightRangeTextBox.Text)))
            {
                MessageBox.Show("Initial Weight is worng. Check Please.");
                initialWeightRangeTextBox.Focus();
                initialWeightRangeTextBox.SelectAll();
            }
            else if (!(RegularExpression.DoubleCheck(decayRateTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(decayRateTextBox.Text)))
            {
                MessageBox.Show("DecayRate Data is worng. Check Please.");
                decayRateTextBox.Focus();
                decayRateTextBox.SelectAll();
            }
            else if (!(RegularExpression.DoubleCheck(learningRateTextBox.Text) || RegularExpression.ScientificNotationDoubleCheck(learningRateTextBox.Text)))
            {
                MessageBox.Show("Learning Rate is worng. Check Please.");
                learningRateTextBox.Focus();
                learningRateTextBox.SelectAll();
            }
            else
            {
                simulator.Momentum              = double.Parse(momentumTextBox.Text);
                simulator.ActivationCriterion   = double.Parse(activationCriterionTextBox.Text);
                simulator.InactivationCriterion = double.Parse(inactivationCriterionTextBox.Text);
                simulator.DecayRate             = double.Parse(decayRateTextBox.Text);
                simulator.WeightRange           = double.Parse(initialWeightRangeTextBox.Text);
                simulator.LearningRate          = double.Parse(learningRateTextBox.Text);


                simulator.IsSet = true;

                layerSetupGroupBox.Enabled  = true;
                bundleSetupGroupBox.Enabled = true;
            }
        }
Ejemplo n.º 2
0
        private void variableAddButton_Click(object sender, EventArgs e)
        {
            if (!RegularExpression.DoubleCheck(startPointTextBox.Text))
            {
                MessageBox.Show("Start point is wrong. Check Please.");
            }
            else if (!RegularExpression.DoubleCheck(endPointTextBox.Text))
            {
                MessageBox.Show("End point is wrong. Check Please.");
            }
            else if (!RegularExpression.DoubleCheck(stepTextBox.Text))
            {
                MessageBox.Show("Step is wrong. Check Please.");
            }
            else if (double.Parse(startPointTextBox.Text) > double.Parse(endPointTextBox.Text))
            {
                MessageBox.Show("Start point is bigger than end point. Check Please.");
            }
            else
            {
                if ((string)variableComboBox.SelectedItem == "Layer-Unit" && (!RegularExpression.PositiveIntCheck(startPointTextBox.Text) || !RegularExpression.PositiveIntCheck(endPointTextBox.Text) || !RegularExpression.PositiveIntCheck(stepTextBox.Text)))
                {
                    MessageBox.Show("Unit always has to be a positive integer.");
                }
                else if (decimal.Parse(endPointTextBox.Text) - decimal.Parse(startPointTextBox.Text) != 0 && (decimal.Parse(endPointTextBox.Text) - decimal.Parse(startPointTextBox.Text)) % decimal.Parse(stepTextBox.Text) != 0.0m)
                {
                    MessageBox.Show("There has to be no remainder in the dividing of the range and the step.");
                }
                else
                {
                    Variable newVariable = new Variable();

                    newVariable.LayerConnectionName = layerConnectionNameTextBox.Text;
                    newVariable.ProcessName         = processNameTextBox.Text;
                    newVariable.StartPoint          = double.Parse(startPointTextBox.Text);
                    newVariable.EndPoint            = double.Parse(endPointTextBox.Text);
                    newVariable.Step = double.Parse(stepTextBox.Text);

                    switch ((string)variableComboBox.SelectedItem)
                    {
                    case "Layer-Unit":
                        newVariable.VariableType = VariableType.Layer_Unit;
                        newVariable.ProcessName  = "";
                        break;

                    case "Layer-DamagedSD":
                        newVariable.VariableType = VariableType.Layer_DamagedSD;
                        break;

                    case "Connection-DamagedSD":
                        newVariable.VariableType = VariableType.Connection_DamagedSD;
                        break;

                    case "Learning Rate":
                        newVariable.VariableType        = VariableType.LearningRate;
                        newVariable.LayerConnectionName = "";
                        newVariable.ProcessName         = "";
                        break;

                    case "Initial Weight":
                        newVariable.VariableType        = VariableType.InitialWeight;
                        newVariable.LayerConnectionName = "";
                        newVariable.ProcessName         = "";
                        break;
                    }

                    bool isExist = false;
                    foreach (Variable variable in variableList)
                    {
                        if (newVariable.VariableType == variable.VariableType && newVariable.LayerConnectionName == variable.LayerConnectionName)
                        {
                            isExist = true;
                            break;
                        }
                    }

                    if (isExist)
                    {
                        MessageBox.Show("There is already same variable.\nIt is impossible to make another variable which has same name and variable type.");
                    }
                    else
                    {
                        variableList.Add(newVariable);
                        VariableList_Refresh();

                        variableComboBox.SelectedIndex  = -1;
                        layerConnectionNameTextBox.Text = "";
                        processNameTextBox.Text         = "";
                        startPointTextBox.Text          = "";
                        endPointTextBox.Text            = "";
                        stepTextBox.Text = "";
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void TestDisplayRefresh()
        {
            if (testDisplayModeComboBox.SelectedIndex < 0)
            {
            }
            else if (!RegularExpression.DoubleCheck(minYAxisTestDisplayTextBox.Text))
            {
                MessageBox.Show("Min Y Axis value is worng. Check Please.");

                minYAxisTestDisplayTextBox.Text = "0.0";
                minYAxisTestDisplayTextBox.Focus();
                minYAxisTestDisplayTextBox.SelectAll();
            }
            else if (!RegularExpression.DoubleCheck(maxYAxisTestDisplayTextBox.Text))
            {
                MessageBox.Show("Max Y Axis value is worng. Check Please.");

                maxYAxisTestDisplayTextBox.Text = "1.0";
                maxYAxisTestDisplayTextBox.Focus();
                maxYAxisTestDisplayTextBox.SelectAll();
            }
            else if (double.Parse(minYAxisTestDisplayTextBox.Text) < 0)
            {
                MessageBox.Show("Min Y Axis value must be 0 or bigger. Check Please.");

                minYAxisTestDisplayTextBox.Text = "0.0";
                maxYAxisTestDisplayTextBox.Focus();
                maxYAxisTestDisplayTextBox.SelectAll();
            }
            else if (double.Parse(maxYAxisTestDisplayTextBox.Text) <= 0)
            {
                MessageBox.Show("Max Y Axis value must be bigger than 0. Check Please.");

                maxYAxisTestDisplayTextBox.Text = "1.0";
                maxYAxisTestDisplayTextBox.Focus();
                maxYAxisTestDisplayTextBox.SelectAll();
            }
            else if (double.Parse(maxYAxisTestDisplayTextBox.Text) <= double.Parse(minYAxisTestDisplayTextBox.Text))
            {
                MessageBox.Show("Max Y Axis value must be bigger than min Y Axis value. Check Please.");

                minYAxisTestDisplayTextBox.Text = "0.0";
                maxYAxisTestDisplayTextBox.Text = "1.0";
                maxYAxisTestDisplayTextBox.Focus();
                maxYAxisTestDisplayTextBox.SelectAll();
            }
            else if (!useTimeStampCheckBox.Checked)
            {
                int maxXAxis = 0;
                foreach (LearningSetup processSetup in learningSetupList)
                {
                    maxXAxis += processSetup.TrainingEpoch;
                }

                testDisplayChart.ChartAreas[0].Area3DStyle.Enable3D = false;

                testDisplayChart.ChartAreas[0].AxisX.Minimum = 0;
                testDisplayChart.ChartAreas[0].AxisX.Maximum = maxXAxis;
                testDisplayChart.ChartAreas[0].AxisY.Minimum = double.Parse(minYAxisTestDisplayTextBox.Text);
                testDisplayChart.ChartAreas[0].AxisY.Maximum = double.Parse(maxYAxisTestDisplayTextBox.Text);

                List <DisplayData> displayDataList = new List <DisplayData>();

                try
                {
                    switch (testDisplayModeComboBox.SelectedIndex)
                    {
                    case 0:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    displayData.InsertValue(testData.MeanSquredError);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch = testData.Epoch;
                                newDisplayData.InsertValue(testData.MeanSquredError);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 1:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    displayData.InsertValue(testData.MeanSemanticStress);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch = testData.Epoch;
                                newDisplayData.InsertValue(testData.MeanSemanticStress);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 2:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    displayData.InsertValue(testData.MeanCrossEntropy);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch = testData.Epoch;
                                newDisplayData.InsertValue(testData.MeanCrossEntropy);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 3:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    if (testData.Correctness)
                                    {
                                        displayData.InsertValue(1);
                                    }
                                    else
                                    {
                                        displayData.InsertValue(0);
                                    }
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch = testData.Epoch;
                                if (testData.Correctness)
                                {
                                    newDisplayData.InsertValue(1);
                                }
                                else
                                {
                                    newDisplayData.InsertValue(0);
                                }
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 4:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    if (testData.MeanActiveUnitActivation == testData.MeanActiveUnitActivation)
                                    {
                                        displayData.InsertValue(testData.MeanActiveUnitActivation);
                                        isExist = true;
                                    }
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                if (testData.MeanActiveUnitActivation == testData.MeanActiveUnitActivation)
                                {
                                    DisplayData newDisplayData = new DisplayData();
                                    newDisplayData.Epoch = testData.Epoch;
                                    newDisplayData.InsertValue(testData.MeanActiveUnitActivation);
                                    displayDataList.Add(newDisplayData);
                                }
                            }
                        }
                        break;

                    case 5:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch)
                                {
                                    if (testData.MeanInactiveUnitActivation == testData.MeanInactiveUnitActivation)
                                    {
                                        displayData.InsertValue(testData.MeanInactiveUnitActivation);
                                        isExist = true;
                                    }
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                if (testData.MeanInactiveUnitActivation == testData.MeanInactiveUnitActivation)
                                {
                                    DisplayData newDisplayData = new DisplayData();
                                    newDisplayData.Epoch = testData.Epoch;
                                    newDisplayData.InsertValue(testData.MeanInactiveUnitActivation);
                                    displayDataList.Add(newDisplayData);
                                }
                            }
                        }
                        break;
                    }
                    testDisplayChart.Series.Clear();
                    testDisplayChart.Legends.Clear();

                    Series dataSeries = new Series();
                    dataSeries.ChartType = SeriesChartType.Line;
                    testDisplayChart.Series.Add(dataSeries);

                    foreach (DisplayData displayData in displayDataList)
                    {
                        DataPoint dataPoint = new DataPoint();
                        dataPoint.SetValueXY(displayData.Epoch, displayData.Value);
                        dataSeries.Points.Add(dataPoint);
                    }
                }
                catch
                {
                }
            }
            else if (useTimeStampCheckBox.Checked)
            {
                int maxXAxis = 0;
                foreach (TestData testData in simulator.TestDataList)
                {
                    if (testData.TimeStamp > maxXAxis)
                    {
                        maxXAxis = testData.TimeStamp;
                    }
                }

                testDisplayChart.ChartAreas[0].Area3DStyle.Enable3D   = true;
                testDisplayChart.ChartAreas[0].Area3DStyle.PointDepth = 50;

                testDisplayChart.ChartAreas[0].AxisX.Minimum = 0;
                testDisplayChart.ChartAreas[0].AxisX.Maximum = maxXAxis;
                testDisplayChart.ChartAreas[0].AxisY.Minimum = double.Parse(minYAxisTestDisplayTextBox.Text);
                testDisplayChart.ChartAreas[0].AxisY.Maximum = double.Parse(maxYAxisTestDisplayTextBox.Text);

                List <DisplayData> displayDataList = new List <DisplayData>();

                try
                {
                    switch (testDisplayModeComboBox.SelectedIndex)
                    {
                    case 0:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    displayData.InsertValue(testData.MeanSquredError);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch     = testData.Epoch;
                                newDisplayData.TimeStamp = testData.TimeStamp;
                                newDisplayData.InsertValue(testData.MeanSquredError);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 1:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    displayData.InsertValue(testData.MeanSemanticStress);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch     = testData.Epoch;
                                newDisplayData.TimeStamp = testData.TimeStamp;
                                newDisplayData.InsertValue(testData.MeanSemanticStress);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 2:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    displayData.InsertValue(testData.MeanCrossEntropy);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch     = testData.Epoch;
                                newDisplayData.TimeStamp = testData.TimeStamp;
                                newDisplayData.InsertValue(testData.MeanCrossEntropy);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 3:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    if (testData.Correctness)
                                    {
                                        displayData.InsertValue(1);
                                    }
                                    else
                                    {
                                        displayData.InsertValue(0);
                                    }
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch     = testData.Epoch;
                                newDisplayData.TimeStamp = testData.TimeStamp;
                                if (testData.Correctness)
                                {
                                    newDisplayData.InsertValue(1);
                                }
                                else
                                {
                                    newDisplayData.InsertValue(0);
                                }
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;

                    case 4:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    if (testData.MeanInactiveUnitActivation == testData.MeanInactiveUnitActivation)
                                    {
                                        displayData.InsertValue(testData.MeanActiveUnitActivation);
                                        isExist = true;
                                    }
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                if (testData.MeanInactiveUnitActivation == testData.MeanInactiveUnitActivation)
                                {
                                    DisplayData newDisplayData = new DisplayData();
                                    newDisplayData.Epoch     = testData.Epoch;
                                    newDisplayData.TimeStamp = testData.TimeStamp;
                                    newDisplayData.InsertValue(testData.MeanActiveUnitActivation);
                                    displayDataList.Add(newDisplayData);
                                }
                            }
                        }
                        break;

                    case 5:
                        foreach (TestData testData in simulator.TestDataList)
                        {
                            bool isExist = false;
                            foreach (DisplayData displayData in displayDataList)
                            {
                                if (testData.Epoch == displayData.Epoch && testData.TimeStamp == displayData.TimeStamp)
                                {
                                    displayData.InsertValue(testData.MeanInactiveUnitActivation);
                                    isExist = true;
                                    break;
                                }
                            }
                            if (!isExist)
                            {
                                DisplayData newDisplayData = new DisplayData();
                                newDisplayData.Epoch     = testData.Epoch;
                                newDisplayData.TimeStamp = testData.TimeStamp;
                                newDisplayData.InsertValue(testData.MeanInactiveUnitActivation);
                                displayDataList.Add(newDisplayData);
                            }
                        }
                        break;
                    }
                    testDisplayChart.Series.Clear();
                    testDisplayChart.Legends.Clear();
                    testDisplayChart.Legends.Add(new Legend());
                    testDisplayChart.Legends[0].Name = "";

                    Dictionary <int, Series> dataSeriesDictionary = new Dictionary <int, Series>();

                    foreach (DisplayData displayData in displayDataList)
                    {
                        if (!dataSeriesDictionary.ContainsKey(displayData.Epoch))
                        {
                            Series newSeries = new Series();
                            newSeries.ChartType = SeriesChartType.Line;
                            newSeries.Name      = "Epoch" + displayData.Epoch.ToString();
                            testDisplayChart.Series.Add(newSeries);
                            dataSeriesDictionary[displayData.Epoch] = newSeries;

                            LegendItem newLegendItem = new LegendItem();
                            newLegendItem.ImageStyle = LegendImageStyle.Line;
                            //newLegendItem.Name = "Epoch" + displayData.Epoch.ToString();
                            newLegendItem.SeriesName = displayData.Epoch.ToString();
                            testDisplayChart.Legends[0].CustomItems.Add(newLegendItem);
                        }
                        DataPoint dataPoint = new DataPoint();
                        dataPoint.SetValueXY(displayData.TimeStamp, displayData.Value);
                        dataSeriesDictionary[displayData.Epoch].Points.Add(dataPoint);
                    }
                }
                catch
                {
                }
            }
        }