예제 #1
0
        } // End run_training

        /*******************************************************************
        *
        * Running the Perceptron
        *
        *******************************************************************/

        /// <summary>
        /// Allows the user to input values and see what the output is based on the given perceptron
        /// </summary>
        /// <param name="perceptron">The perceptron for the user to check inputs and their respective outputs</param>
        public void run()
        {
            do
            {
                foreach (Neuron temp in perceptron.Value)
                {
                    Console.WriteLine("Give an Input of 0, 1, true, or false: ");
                    temp.UpdateInputValues(DataValidation.get_boolean());
                }
                Console.WriteLine("Output value of: " + perceptron.Key.Calculate());
                Console.WriteLine("Continue?  y/n");
            } while (DataValidation.yes_no());
        }
예제 #2
0
        /*******************************************************************
        *
        * Perceptron Training Methods
        *
        *******************************************************************/

        /// <summary>
        /// Suser built build the training set method
        /// </summary>
        /// <returns>The trained perceptront</returns>
        public void user_built_perceptron()
        {
            // Initialize training set
            List <KeyValuePair <Boolean, Boolean[]> > training_set = new List <KeyValuePair <bool, bool[]> >();

            Console.WriteLine("How many neurons are in the input?");
            int size = 0;

            size = DataValidation.get_int();

            do
            {
                Boolean[] inputs = new Boolean[size];
                Boolean   output;

                Console.WriteLine("All inputs should either be 0, 1, true, or false");

                for (int i = 0; i < size; ++i)
                {
                    Console.WriteLine("Input for " + i + ": ");
                    inputs[i] = DataValidation.get_boolean();
                }

                Console.WriteLine("Expected output: ");
                output = DataValidation.get_boolean();

                training_set.Add(new KeyValuePair <bool, bool[]>(output, inputs));

                Console.WriteLine("Add another training set?\ny/n");
            } while (DataValidation.yes_no());

            Console.WriteLine("What is the output neuron's activation threshold?");
            Double thresh = Double.Parse(Console.ReadLine());

            perceptron = run_training(training_set, thresh);
        } // End user_built_perceptron