Esempio n. 1
0
 static void Main()
 {
     TicTacToeValueLoader.LoadAllUniqueStates(Storage.Instance, TicTacToeValueNetwork.DefaultInputTransform);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new TicTacToeForm());
 }
Esempio n. 2
0
        public TicTacToeValueNetwork CreateTrainedNetwork()
        {
            var trainingData = TicTacToeValueLoader.LoadAllUniqueStates(Storage.Instance);
            var trainer      = new TicTacToeValueNetworkTrainer(trainingData, 0);

            return(trainer.Train(30));
        }
Esempio n. 3
0
        public static void LoadValueNetworkAndTestOnAllStates()
        {
            string modelPath = @"C:\Users\pstepnowski\Source\Repos\fdafadf\basics\Workspace\TicTacToeKerasModel.bin";

            Console.WriteLine($"Loading Testing Data");
            var testingData = TicTacToeValueLoader.LoadAllUniqueStates(null);

            //TicTacToeTrainingData.Load(TicTacToeNeuralIOLoader.InputTransforms.Bipolar, out double[][] inputs, out TicTacToeResultProbabilities[] outputs);
            Console.WriteLine($"Loading Model");
            var model = new KerasModel(() => BaseModel.LoadModel(modelPath));

            Console.WriteLine($"Testing Model (All Possible States)");
            TestModel(model, testingData, (l, p, i) => false, out int correct, out int wrong);;
            Console.WriteLine(string.Format("Correct: {0}", correct));
            Console.WriteLine(string.Format("Wrong: {0}", wrong));
        }
Esempio n. 4
0
        public static void Compare3()
        {
            int epoches = 30;
            var data    = TicTacToeValueLoader.LoadAllUniqueStates(Storage.Instance);
            List <Optimizer> optimizers = new List <Optimizer>();

            optimizers.Add(SGDMomentum(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001, 0.04));
            optimizers.Add(SGDMomentum(Network(LEAKY, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001, 0.04));
            ChartForm chartForm = new ChartForm("TicTacToe");

            foreach (var optimizer in optimizers)
            {
                chartForm.Add(optimizer, Train(optimizer, data, epoches, 1, Monitors(MSE)));
            }

            chartForm.ShowDialog();
        }
Esempio n. 5
0
        public static void Compare4()
        {
            int epoches = 600;
            var data    = TicTacToeValueLoader.LoadAllUniqueStates(Storage.Instance);
            //List<Optimizer> optimizers = new List<Optimizer>();
            var optimizer1 = SGDMomentum(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001, 0.04);
            var optimizer2 = SGDMomentum(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001, 0.04);
            var optimizer3 = SGDMomentum(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001, 0.04);
            var optimizer4 = AdaGrad(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.01);
            //optimizers.Add(AdaGrad(Network(RELU, 9, 3, 72, 72, 72, 36, 36, 36, 18, 18), 0.001));
            ChartForm chartForm = new ChartForm("TicTacToe");

            //chartForm.Add(optimizer1, Train(optimizer1, @in, @out, epoches, 1, Monitors(MSE)));
            //chartForm.Add(optimizer2, Train(optimizer2, @in, @out, epoches, 8, Monitors(MSE)));
            chartForm.Add(optimizer3, Train(optimizer3, data, epoches, 32, Monitors(MSE)));
            chartForm.Add(optimizer4, Train(optimizer4, data, epoches, 32, Monitors(MSE)));
            chartForm.ShowDialog();
        }
Esempio n. 6
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;
            });
        }