Encog.Neural.Flat.FlatNetwork.Randomize C# (CSharp) Method

Randomize() public method

Perform a simple randomization of the weights of the neural network between -1 and 1.
public Randomize ( ) : void
return void
        public void Randomize()
        {
            Randomize(1, -1);
        }

Same methods

FlatNetwork::Randomize ( double hi, double lo ) : void

Usage Example

Exemplo 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]);
            }
        }
All Usage Examples Of Encog.Neural.Flat.FlatNetwork::Randomize