コード例 #1
0
        static void Main()
        {
            Console.WriteLine("********************************************");
            Console.WriteLine("Neural Networks - Project No.2 - BAM network");
            Console.WriteLine("********************************************");

            #region Prepare the data

            // initialize output vectors - phone numbers
            var phoneNumbers = new[] { "3120440569", "9114567896", "0538795012", "1234567890", "0508656789" };

            // initializing input vectors - 16 bit icons
            var db = ReadIcons(phoneNumbers);

            Console.WriteLine("\nAssociations Icons: \n");
            foreach (var icon in db)
                Console.WriteLine(icon.ToString(1));

            #endregion

            // initialize the BAM neural network wrapper
            var bamNeuralNetworkWrapper = new BamNetworkPhoneToIconsWrapper(db,
                new PhoneNumberToBiPolarConvertorHuffmanCode(new BinaryToBiPolarVecConvertor()),
                new BinaryToBiPolarVecConvertor());

            Console.WriteLine("Test BAM Network : \n");

            TestInputIconsWithErrorPerentage(db, bamNeuralNetworkWrapper,  0 ,1);
            TestInputIconsWithErrorPerentage(db, bamNeuralNetworkWrapper, 20, 5);
            TestInputIconsWithErrorPerentage(db, bamNeuralNetworkWrapper, 50, 5);
        }
コード例 #2
0
        private static void TestInputIconsWithErrorPerentage(IEnumerable<IconInputDataStructure> db,
            BamNetworkPhoneToIconsWrapper bamNeuralNetworkWrapper, int errorPercentage, int numberOfTests)
        {
            Console.WriteLine("Test the input icons with " + errorPercentage + "% random Error");

            // check all the input icons
            foreach (var iconInputDataStructure in db)
            {
                Console.ReadKey();
                Console.WriteLine("\tInputIcon: ");
                Console.WriteLine(iconInputDataStructure.ToString(2));

                // create random error icons and test the result
                for (var i = 0; i < numberOfTests; i++)
                {
                    Console.ReadKey();
                    Console.WriteLine("\t\t" + errorPercentage +  "% random error icon:");
                    var errorIcon = iconInputDataStructure.CreateError(errorPercentage);
                    Console.WriteLine(errorIcon.ToString(3));

                    // output results
                    Console.WriteLine("\t\tOutputIcon:");
                    Console.WriteLine(bamNeuralNetworkWrapper.Associate(errorIcon).ToString(3));
                }
            }
        }