示例#1
0
        static void ExecuteSeries(Scenario scenario, Pattern testPattern)
        {
            int matchCount    = 0;
            int nonMatchCount = 0;

            for (int i = 0; i < 1000; i++)
            {
                try
                {
                    var network = new HopfieldNetwork();
                    network.TeachWithHebbsRule(scenario);

                    var testingVector = Vector <double> .Build.DenseOfArray(testPattern.CreateVectorData(7, 7));

                    var outputVector  = network.Test(new NeuralVector(testingVector));
                    var outputPattern = Helper.MapToPattern(outputVector, scenario.LineCount, scenario.ColumnCount);

                    if (outputPattern.IsEqualValue(testPattern))
                    {
                        matchCount++;
                    }
                    else
                    {
                        nonMatchCount++;
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Error on Test");
                    Console.WriteLine(exception);
                }
            }
            Console.Write($"Ergebnis: Korrekt {matchCount} - Falsch {nonMatchCount}");
        }
示例#2
0
        static void ExecuteSingle(Scenario scenario, Pattern testPattern)
        {
            try
            {
                var network = new HopfieldNetwork();
                network.TeachWithHebbsRule(scenario);

                var testingVector = Vector <double> .Build.DenseOfArray(testPattern.CreateVectorData(7, 7));

                var outputVector  = network.Test(new NeuralVector(testingVector));
                var outputPattern = Helper.MapToPattern(outputVector, scenario.LineCount, scenario.ColumnCount);

                Console.WriteLine("Ergebnis");
                Console.WriteLine(outputPattern);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error on Test");
                Console.WriteLine(exception);
            }
        }