Ejemplo n.º 1
0
 public Preprocessor(List <string> files, Set <string> ingates, Dictionary <string, string> canonical_examples, bool verbosity)
 {
     _verbose = verbosity;
     _td      = new TrainingData(WIDTH, HEIGHT);
     _gates   = ingates;
     if (_verbose)
     {
         Console.WriteLine("Beginning search for {0} gate types", _gates.Count);
     }
     foreach (string file in files)
     {
         if (_verbose)
         {
             Console.Write(".");
         }
         Sketch.Sketch input = new ConverterXML.ReadXML(file).Sketch;
         addGatesFrom(input);
     }
     foreach (KeyValuePair <string, string> ce in canonical_examples)
     {
         Sketch.Sketch input = new ConverterXML.ReadXML(ce.Value).Sketch;
         addCanonicalExample(ce.Key, input);
     }
     if (_verbose)
     {
         Console.Write(Environment.NewLine);
         Console.WriteLine("SUMMARY:");
         foreach (string gate in _gates)
         {
             Console.WriteLine("Found {0} {1}s", _td.Images(gate).Count, gate);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads a new TrainingData object from a file
        /// </summary>
        /// <param name="filename">The file to read from</param>
        /// <returns>The TrainingData object</returns>
        public static TrainingData ReadFromFile(string filename)
        {
            Stream          stream = File.Open(filename, FileMode.Open);
            BinaryFormatter fmt    = new BinaryFormatter();
            TrainingData    td     = (TrainingData)fmt.Deserialize(stream);

            stream.Close();
            return(td);
        }