static void Main(string[] args)
        {
            Random seed = new Random();

            CrossValidate(seed);
            return;

            Console.WriteLine("Start time: " + DateTime.Now.ToString());

            DatasetParser datasetParser = new DatasetParser();

            Example[] examples = datasetParser.parseDatasetFile(EXAMPLES_FILENAME);
            Shuffle(examples, seed);

            CharacterRecognition cr = new CharacterRecognition(NUM_NETWORKS,
                                                               NETWORK_NUM_INPUTS, NETWORK_NUM_OUTPUTS,
                                                               NETWORK_NUM_HIDDEN_LAYERS, NETWORK_NUM_NEURONS_PER_HIDDEN_LAYER, seed);

            cr.Initialize(examples);

            /*while (true)
             * {
             *  double[] input = null;
             *  double[] output = cr.RecognizeCharacter(input);
             *
             * foreach(double d in output){Console.Write(d+", ");}Console.WriteLine();
             * }*/

            /*Console.WriteLine("Guessing: ");
             * cr.RecognizeCharacter(new double[] {
             *  0, 1, 0, 0,
             *  0, 1, 0, 0,
             *  0, 1, 1, 0,
             *  0, 0, 1, 0
             * });
             *
             * cr.RecognizeCharacter(new double[] {
             *  0, 1, 1, 0,
             *  1, 1, 0, 1,
             *  0, 0, 1, 1,
             *  0, 0, 1, 0
             * });*/

            Console.WriteLine("Guessing: ");
            cr.RecognizeCharacter(new double[] {
                0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
                0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
                0, 0, 1, 1, 0, 0, 0, 0, 0, 1,
                0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
                1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 1, 1, 1, 0, 0, 0, 0, 0, 1,
                0, 0, 1, 1, 1, 0, 0, 0, 1, 1,
                0, 0, 0, 0, 1, 1, 1, 1, 1, 0,
                0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
            });
        }
Example #2
0
        public void Generate(Random seed)
        {
            DatasetParser datasetParser = new DatasetParser();

            Example[] examples = datasetParser.parseDatasetFile(EXAMPLES_FILENAME);
            Shuffle(examples, seed);

            this.characterRecognizer = new CharacterRecognition(NUM_NETWORKS,
                                                                NETWORK_NUM_INPUTS, NETWORK_NUM_OUTPUTS,
                                                                NETWORK_NUM_HIDDEN_LAYERS, NETWORK_NUM_NEURONS_PER_HIDDEN_LAYER, seed);
            this.characterRecognizer.Initialize(examples);
        }
Example #3
0
        public double CrossValidate(Random seed)
        {
            //Console.WriteLine("Start time: " + DateTime.Now.ToString());
            DatasetParser datasetParser = new DatasetParser();

            Example[] examples = datasetParser.parseDatasetFile(this.EXAMPLES_FILENAME);

            CharacterRecognition cr = new CharacterRecognition(this.NUM_NETWORKS,
                                                               NETWORK_NUM_INPUTS, NETWORK_NUM_OUTPUTS,
                                                               NETWORK_NUM_HIDDEN_LAYERS, NETWORK_NUM_NEURONS_PER_HIDDEN_LAYER
                                                               , seed);

            CrossValidation cv        = new CrossValidation(examples, 5, ref cr, seed);
            double          precision = cv.CalculatePrecision(ref examples);

            //Console.WriteLine(1.0 - precision);
            //Console.WriteLine("End time: " + DateTime.Now.ToString());
            return(1.0 - precision);
        }
        public static void CrossValidate(Random seed)
        {
            DatasetParser datasetParser;

            Example[]            examples;
            CharacterRecognition cr;
            CrossValidation      cv;


            NetworkEvolution.GENERATIONS_NUMBER = 20000;
            NetworkEvolution.STAGNANT_NUMBER    = 50;
            Console.WriteLine("-------stag50||its20000_mut0,003_pop20_30_L1_70-------------------------");
            Console.WriteLine("Start time: " + DateTime.Now.ToString());
            datasetParser = new DatasetParser();
            examples      = datasetParser.parseDatasetFile(EXAMPLES_FILENAME);
            cr            = new CharacterRecognition(NUM_NETWORKS,
                                                     NETWORK_NUM_INPUTS, NETWORK_NUM_OUTPUTS,
                                                     1, new int[] { 70 }, seed);
            cv = new CrossValidation(examples, 5, ref cr, seed);
            Console.WriteLine(cv.CalculatePrecision(ref examples));
            Console.WriteLine("End time: " + DateTime.Now.ToString());
        }