Compute() public method

Calculate the output for the given input.
public Compute ( double input, double output ) : void
input double The input.
output double Output will be placed here.
return void
Esempio n. 1
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            var network = new FlatNetwork(2, 4, 0, 1, false);
            network.Randomize();

            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);


            var train = new TrainFlatNetworkResilient(network, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            var output = new double[1];
            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                double[] input = pair.Input.Data;
                network.Compute(input, output);
                Console.WriteLine(input[0] + @"," + input[1] + @":" + output[0]);
            }
        }
Esempio n. 2
0
        public static void Evaluate(FlatNetwork network, IMLDataSet trainingSet)
        {
            double[] output = new double[1];
            foreach (IMLDataPair pair in trainingSet)
            {
                network.Compute(pair.Input.Data, output);
                Console.WriteLine(pair.Input.Data[0] + @"," + pair.Input[1]
                        + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }

        }