AForge.Neuro.Learning.ElasticNetworkLearning.ElasticNetworkLearning C# (CSharp) Method

ElasticNetworkLearning() public method

Initializes a new instance of the ElasticNetworkLearning class.
public ElasticNetworkLearning ( DistanceNetwork network ) : System
network DistanceNetwork Neural network to train.
return System
        public ElasticNetworkLearning( DistanceNetwork network )
        {
            this.network = network;

            // precalculate distances array
            int neurons = network.Layers[0].Neurons.Length;
            double deltaAlpha = Math.PI * 2.0 / neurons;
            double alpha = deltaAlpha;

            distance = new double[neurons];
            distance[0] = 0.0;

            // calculate all distance values
            for ( int i = 1; i < neurons; i++ )
            {
                double dx = 0.5 * Math.Cos( alpha ) - 0.5;
                double dy = 0.5 * Math.Sin( alpha );

                distance[i] = dx * dx + dy * dy;

                alpha += deltaAlpha;
            }
        }