private void LayerNumber_Changed(object sender, KeyEventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
                var splits = t.Name.Split('_');
                int.TryParse(splits[1], out int whichLayer);
                int.TryParse(t.Text, out int howMany);
                howMany = MathHandler.Clamp(howMany, NeuralNetwork.NeuronMin, NeuralNetwork.NeuronMax);
                t.Text  = howMany.ToString();
                _ann.UpdateLayer(whichLayer, howMany);
                break;

            case Keys.Escape:
                splits = t.Name.Split('_');
                int.TryParse(splits[1], out whichLayer);
                t.Text = _ann.GetArchitecture()[whichLayer].ToString();
                break;
            }
        }
        private void DesiredError_Left(object sender, EventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            double.TryParse(t.Text, out double desiredError);
            desiredError = MathHandler.Clamp(desiredError, NeuralNetwork.DesiredErrorMin, NeuralNetwork.DesiredErrorMax);
            t.Text       = desiredError.ToString(CultureInfo.InvariantCulture);
            _ann.ChangeDesiredError(desiredError);
        }
        private void Eta_Left(object sender, EventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            double.TryParse(t.Text, out double eta);
            eta    = MathHandler.Clamp(eta, NeuralNetwork.EtaMin, NeuralNetwork.EtaMax);
            t.Text = eta.ToString(CultureInfo.InvariantCulture);
            _ann.ChangeEta(eta);
        }
Exemplo n.º 4
0
        public static int TextBoxLeft(object sender, EventArgs e, int valueToBeChanged, int min, int max)
        {
            if (!(sender is TextBox t))
            {
                return(valueToBeChanged);
            }

            int.TryParse(t.Text, out int value);
            value  = MathHandler.Clamp(value, min, max);
            t.Text = value.ToString(CultureInfo.InvariantCulture);
            return(value);
        }
        private void LayerNumber_Left(object sender, EventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            var splits = t.Name.Split('_');

            int.TryParse(splits[1], out int whichLayer);
            int.TryParse(t.Text, out int howMany);
            howMany = MathHandler.Clamp(howMany, NeuralNetwork.NeuronMin, NeuralNetwork.NeuronMax);
            t.Text  = howMany.ToString();
            _ann.UpdateLayer(whichLayer, howMany);
        }
        private void DesiredError_Changed(object sender, KeyEventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
                double.TryParse(t.Text, out double desiredError);
                desiredError = MathHandler.Clamp(desiredError, NeuralNetwork.DesiredErrorMin, NeuralNetwork.DesiredErrorMax);
                t.Text       = desiredError.ToString(CultureInfo.InvariantCulture);
                _ann.ChangeDesiredError(desiredError);
                break;

            case Keys.Escape:
                t.Text = _ann.GetDesiredError().ToString(CultureInfo.InvariantCulture);
                break;
            }
        }
        private void Eta_Changed(object sender, KeyEventArgs e)
        {
            if (!(sender is TextBox t))
            {
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
                double.TryParse(t.Text, out double eta);
                eta    = MathHandler.Clamp(eta, NeuralNetwork.EtaMin, NeuralNetwork.EtaMax);
                t.Text = eta.ToString(CultureInfo.InvariantCulture);
                _ann.ChangeEta(eta);
                break;

            case Keys.Escape:
                t.Text = _ann.GetEta().ToString(CultureInfo.InvariantCulture);
                break;
            }
        }
Exemplo n.º 8
0
        public static int TextBoxChanged(object sender, KeyEventArgs e, int valueToBeChanged, int min, int max)
        {
            if (!(sender is TextBox t))
            {
                return(valueToBeChanged);
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
                int.TryParse(t.Text, out int value);
                value  = MathHandler.Clamp(value, min, max);
                t.Text = value.ToString(CultureInfo.InvariantCulture);
                return(value);

            case Keys.Escape:
                t.Text = valueToBeChanged.ToString(CultureInfo.InvariantCulture);
                break;
            }
            return(valueToBeChanged);
        }