private static void PrettyPrint()
        {
            while (true)
            {
                PrintPrettyPrintOptions();

                SharedConsoleCommands.YourInput();
                var input = Colorful.Console.ReadLine();
                ITrainingDatasetDefinition datasetDefinition;
                switch (input)
                {
                case EXIT_CHOICE:
                    return;

                case DIGITS_CHOICE:
                    datasetDefinition = new EMNISTDigitDataset();
                    break;

                case LETTERS_CHOICE:
                    datasetDefinition = new EMNISTLetterDataset();
                    break;

                case UPPERCASE_LETTERS_CHOICE:
                    datasetDefinition = new EMNISTUppercaseLetterDataset();
                    break;

                default:
                    SharedConsoleCommands.InvalidCommand(input);
                    continue;
                }

                try
                {
                    Colorful.Console.WriteLine("Choose line:", Color.Gray);
                    CntkDatasetRow prettyPrintInput = null;
                    try
                    {
                        var inputLineNum = Int32.Parse(Colorful.Console.ReadLine());
                        prettyPrintInput =
                            new CntkEmnistDatasetStreamFetcher().GetRowFromDefinition(datasetDefinition, inputLineNum);
                    }
                    catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException)
                    {
                        Colorful.Console.WriteLine($"Not a valid line number!", Color.IndianRed);
                        continue;
                    }
                    new CntkEmnistDatasetStreamPrinter().PrettyPrint(prettyPrintInput);
                }
                catch (InvalidEmnistDatasetFeatureLengthException)
                {
                    Colorful.Console.WriteLine($"Feature stream is not of length 28*28. Cannot pretty print it.", Color.Gray);
                }
            }
        }
Exemplo n.º 2
0
 private static void PrintOptions()
 {
     Colorful.Console.WriteLine("\nMAIN MODULE", Color.Orange);
     Colorful.Console.WriteLine("\nOptions:");
     Colorful.Console.WriteLine($"    '{DIGITS_CHOICE}' - will train model for digits from EMNIST dataset", Color.Gray);
     Colorful.Console.WriteLine($"    '{LETTERS_CHOICE}' - will train model for letters from EMNIST dataset", Color.Gray);
     Colorful.Console.WriteLine($"    '{UPPERCASE_LETTERS_CHOICE}' - will train model for uppercase letters from EMNIST dataset", Color.Gray);
     Colorful.Console.WriteLine($"    '{PRETTY_PRINT_CHOICE}' - will pretty print pasted features of one " +
                                $"EMNIST dataset feature line", Color.Gray);
     Colorful.Console.WriteLine($"    '{EXIT_CHOICE}' - will terminate application", Color.Gray);
     SharedConsoleCommands.YourInput();
 }
Exemplo n.º 3
0
        private static void RunEmnistTraining(string choice)
        {
            ITrainingDatasetDefinition datasetDefinition = null;

            switch (choice)
            {
            case LETTERS_CHOICE:
                datasetDefinition = new EMNISTLetterDataset();
                break;

            case DIGITS_CHOICE:
                datasetDefinition = new EMNISTDigitDataset();
                break;

            case UPPERCASE_LETTERS_CHOICE:
                datasetDefinition = new EMNISTUppercaseLetterDataset();
                break;

            default:
                SharedConsoleCommands.InvalidCommand(choice);
                return;
            }

            TrainingSessionStart(choice);
            var msgPrinter = new ConsolePrinter();

            var outputDir             = $"./{DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture)}/";
            var device                = DeviceDescriptor.GPUDevice(0);
            var trainingConfiguration = new TrainingSessionConfiguration
            {
                Epochs = 200,
                DumpModelSnapshotPerEpoch  = true,
                ProgressEvaluationSeverity = EvaluationSeverity.PerEpoch,
                MinibatchConfig            = new MinibatchConfiguration
                {
                    MinibatchSize = 64,
                    HowManyMinibatchesPerSnapshot      = (60000 / 32),
                    HowManyMinibatchesPerProgressPrint = 500,
                    DumpModelSnapshotPerMinibatch      = false,
                    AsyncMinibatchSnapshot             = false
                },
                PersistenceConfig = TrainingModelPersistenceConfiguration.CreateWithAllLocationsSetTo(outputDir)
            };

            msgPrinter.PrintMessage("\n" + trainingConfiguration + "\n");

            using (var runner = new ConvolutionalNeuralNetworkRunner(device, trainingConfiguration, msgPrinter))
            {
                runner.RunUsing(datasetDefinition);
            }

            EmnistTrainingDone(choice);
        }
Exemplo n.º 4
0
        public static void Main()
        {
            Colorful.Console.SetWindowSize(110, 30);
            Colorful.Console.BackgroundColor = Color.Black;
            Colorful.Console.ForegroundColor = Color.GhostWhite;

            SayHello();

            while (true)
            {
                PrintOptions();

                string input = Colorful.Console.ReadLine();

                switch (input)
                {
                case EXIT_CHOICE:
                    goto exit;

                case PRETTY_PRINT_CHOICE:
                    PrettyPrintConsoleSubmodule.RunSubmodule();
                    continue;

                case LETTERS_CHOICE:
                case DIGITS_CHOICE:
                case UPPERCASE_LETTERS_CHOICE:
                    EmnistTrainingConsoleSubmodule.RunSubmodule(input);
                    break;

                default:
                    SharedConsoleCommands.InvalidCommand(input);
                    continue;
                }
            }

exit:
            {
                Colorful.Console.WriteLine("Press key to close...", Color.Yellow);
                Colorful.Console.ReadKey();
            }
        }