AForge.Neuro.Learning.SOMLearning.RunEpoch C# (CSharp) Method

RunEpoch() public method

Runs learning epoch.

The method runs one learning epoch, by calling Run method for each vector provided in the input array.

public RunEpoch ( double input ) : double
input double Array of input vectors.
return double
        public double RunEpoch( double[][] input )
        {
            double error = 0.0;

            // walk through all training samples
            foreach ( double[] sample in input )
            {
                error += Run( sample );
            }

            // return summary error
            return error;
        }
    }

Usage Example

Ejemplo n.º 1
0
        // Worker thread
        void SearchSolution( )
        {
            // set random generators range
            Neuron.RandRange = new DoubleRange( 0, Math.Max( pointsPanel.ClientRectangle.Width, pointsPanel.ClientRectangle.Height ) );

            // create network
            DistanceNetwork network = new DistanceNetwork( 2, networkSize * networkSize );

            // create learning algorithm
            SOMLearning	trainer = new SOMLearning( network, networkSize, networkSize );

            // create map
            map = new int[networkSize, networkSize, 3];

            double	fixedLearningRate = learningRate / 10;
            double	driftingLearningRate = fixedLearningRate * 9;

            // iterations
            int i = 0;

            RefreshDelegate refreshIterationsBox = delegate () {
                currentIterationBox.Text = i.ToString( );
            };

            RefreshDelegate enableControls = delegate () {
                EnableControls( true );
            };

            // loop
            while ( !needToStop )
            {
                trainer.LearningRate = driftingLearningRate * ( iterations - i ) / iterations + fixedLearningRate;
                trainer.LearningRadius = (double) learningRadius * ( iterations - i ) / iterations;

                // run training epoch
                trainer.RunEpoch( trainingSet );

                // update map
                UpdateMap( network );

                // increase current iteration
                i++;

                // set current iteration's info
                this.Invoke(refreshIterationsBox);

                // stop ?
                if ( i >= iterations )
                    break;
            }

            // enable settings controls
            this.Invoke(enableControls);
        }
All Usage Examples Of AForge.Neuro.Learning.SOMLearning::RunEpoch