示例#1
0
        private void StartTraining()
        {
            TrainingSettings settings = new TrainingSettings
            {
                Layers       = textBoxLayers.Text.Split(',').Select(v => int.Parse(v)).ToArray(),
                Epoches      = (int)numericEpoches.Value,
                LearningRate = (double)numericLearningRate.Value,
                Momentum     = (double)numericMomentum.Value
            };

            progressBarTraining.Maximum = settings.Epoches;
            labelMeanSquareError.Text   = $"{double.PositiveInfinity}";
            labelAccuracy.Text          = string.Empty;
            labelEpoch.Text             = string.Empty;
            buttonTrained.Enabled       = false;
            tabControl1.SelectedIndex   = 1;
            workerTrain.RunWorkerAsync(settings);
        }
示例#2
0
        private void Training(TrainingSettings settings)
        {
            var trainingData = TicTacToeValueLoader.LoadAllUniqueStates(Storage.Instance, TicTacToeValueNetwork.DefaultInputTransform);
            var trainer      = new TicTacToeValueNetworkTrainer(trainingData, 0)
            {
                HiddenLayerSizes = settings.Layers,
                LearingRate      = settings.LearningRate,
                Momentum         = settings.Momentum,
            };

            TrainedNetwork = trainer.Train(settings.Epoches, new TrainingMonitor(this));

            Invoke((MethodInvoker) delegate()
            {
                var accuracy          = AccuracyMonitor.CalculateAccuracy(TrainedNetwork, trainingData);
                labelAccuracy.Text    = $"{accuracy.CorrectPredictions}/{accuracy.TestingSetSize} ({accuracy.Value * 100.0:f2}%)";
                buttonTrained.Enabled = true;
            });
        }