Exemple #1
0
        public static string LayerTeachingPairFileEntry(NetworkTeachingPair pair)
        {
            string input  = string.Join(",", pair.Input);
            string output = string.Join(",", pair.Output);

            return(string.Format("[{0}:{1}|{2}:{3}]", INPUT_TAG, input, OUTPUT_TAG, output));
        }
Exemple #2
0
        public static KeyValuePair <string, NetworkTeachingPair> ParsePatternDictEntry(string str)
        {
            string[]            patternDictEntry = str.Split(":".ToCharArray(), 2);
            string              patternName      = patternDictEntry[0];
            NetworkTeachingPair pair             = ParseLayerTeachingPair(patternDictEntry[1]);

            return(new KeyValuePair <string, NetworkTeachingPair>(patternName, pair));
        }
Exemple #3
0
        public static void SavePatternDictionaryToFile(string filename)
        {
            PatternDictionary dict = PatternDictionary.GetInstance();

            using (StreamWriter writer = new StreamWriter(new FileStream(filename, FileMode.Create)))
            {
                foreach (var entry in dict.Entries)
                {
                    NetworkTeachingPair pair = entry.Value;
                    writer.WriteLine(string.Format("{0}:{1}", entry.Key, LayerTeachingPairFileEntry(pair)));
                }
            }
        }
Exemple #4
0
        public void PutPattern(string patternName, double[] input)
        {
            NetworkTeachingPair pair = new NetworkTeachingPair(input, GeneratePerceptronOutput());

            try
            {
                patternToLayerTeachingPair.Add(patternName, pair);
            }
            catch (ArgumentException)
            {
                patternToLayerTeachingPair[patternName] = pair;
            }
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Added pattern: {0} => {1}", patternName, pair);
            }
        }