private static void SetupMenu() { bool menuReturn = false; bool falseInput = false; while (!menuReturn) { Console.Clear(); Console.WriteLine("[0] Get Chess Games\t[1] Initialize Weights\t[2] Return to Main Menu"); string input = Console.ReadLine(); switch (input) { case "0": Console.WriteLine("\tChess Games are used from \"http://www.chessgames.com\""); int sampleSize = 0, offset = 0; falseInput = getConsoleInput("\tSample Size: ", ref sampleSize); if (!falseInput) { falseInput = getConsoleInput("\tSample Size: ", ref offset); } if (!falseInput) { DataBase.GetChessGames(sampleSize, offset); } break; case "1": WeightManager.InitializeWeights(Dimensions); ChangeParameters(); break; case "2": menuReturn = true; break; default: Console.WriteLine("Please enter a valid command"); Console.ReadKey(); break; } if (!menuReturn) { Console.WriteLine("Complete.\nPress any key to continue..."); Console.ReadKey(); } Console.Clear(); } }
private static void WeightManagerMenu() { bool menuReturn = false; while (!menuReturn) { Console.Clear(); Console.WriteLine("[0] Save Weights\t[1] Load Weights\t([2] Delete Weights)\n[3] Return to Main Menu"); string input = Console.ReadLine(); switch (input) { case "0": getConsoleInput <string>("\tName of Saved Weights: ", ref input); WeightManager.SaveWeights(input); break; case "1": WeightManager.LoadWeights(); break; case "2": break; case "3": menuReturn = true; break; default: Console.WriteLine("Please enter a valid command"); Console.ReadKey(); break; } if (!menuReturn) { Console.WriteLine("Complete.\nPress any key to continue..."); Console.ReadKey(); } Console.Clear(); } }
public static bool RunRNN() { int offset = 0; bool[] validInputs = new bool[3]; validInputs[0] = Program.getConsoleInput <int>("\tOffset: ", ref offset); validInputs[1] = Program.getConsoleInput <int>("\tTraining Samples: ", ref Program.Dimensions[5]); validInputs[2] = Program.getConsoleInput <int>("\tEpochs: ", ref Program.Dimensions[4]); Console.WriteLine(); for (int i = 0; i < 3; i++) { if (validInputs[i]) { return(true); } } if (RNN_Chess == null) { //DataBase.ConvertdefaultInput(); DataBase.GetWorkspaceSize(offset, Program.Dimensions[5]); if (Variables.InputWeights == null) { WeightManager.WeightReader(); } RNN_Chess = new ManagedObject(Program.Dimensions); RNN_Chess.InitializeVariables(Variables.InputWeights, Variables.HiddenWeights, Variables.Biases); RNN_Chess.InitializeConstants(Program.learningrate); } Stopwatch sw = new Stopwatch(); sw.Start(); for (int o = 0; o < Program.Dimensions[4]; o++) { for (int i = 0; i < Program.Dimensions[5]; i++) { DataBase.ConvertChessNotation(offset + i); RNN_Chess.UpdateDimensions(Program.Dimensions); for (int j = 0; j < Program.Dimensions[0]; j++) { Variables.Results = RNN_Chess.RunRNN(Variables.InputState[j], Program.Dimensions[1]); } for (int j = 0; j < Program.Dimensions[0]; j++) { RNN_Chess.ErrorCalculation(Variables.winningColor); } RNN_Chess.BackPropagation(); } RNN_Chess.UpdateWeightMatrices(Variables.InputWeights, Variables.HiddenWeights, Variables.Biases); } WeightManager.WeightWriter(); RNN_Chess.FreeWorkSpace(); sw.Stop(); Console.WriteLine("Time spent:\t\t" + (float)sw.Elapsed.TotalMilliseconds / 1000 + " s"); Console.WriteLine("Time per Game:\t\t" + (float)sw.Elapsed.TotalMilliseconds / (1000 * Program.Dimensions[4] * Program.Dimensions[5]) + " s\n"); RNN_Chess = null; Variables.ResetVariables(); return(false); }