Esempio n. 1
0
        /// <summary>
        /// Return a clone of this neural network. Including structure, weights and
        /// threshold values.
        /// </summary>
        /// <returns>A cloned copy of the neural network.</returns>
        public Object Clone()
        {
            FeedforwardNetwork result = CloneStructure();

            Double[] copy = MatrixCODEC.NetworkToArray(this);
            MatrixCODEC.ArrayToNetwork(copy, result);
            return(result);
        }
        /// <summary>
        /// Randomize the weights and thresholds. This function does most of the work
        /// of the class. Each call to this class will randomize the data according
        /// to the current temperature. The higher the temperature the more
        /// randomness.
        /// </summary>
        override public void Randomize()
        {
            Random rand = new Random();

            double[] array = MatrixCODEC.NetworkToArray(this.network);

            for (int i = 0; i < array.Length; i++)
            {
                double add = 0.5 - (rand.NextDouble());
                add     /= this.StartTemperature;
                add     *= this.temperature;
                array[i] = array[i] + add;
            }

            MatrixCODEC.ArrayToNetwork(array, this.network);
        }
 /// <summary>
 /// Update the neural network from the gene values.
 /// </summary>
 public void UpdateNetwork()
 {
     MatrixCODEC.ArrayToNetwork(this.Genes, this.network);
 }
 /// <summary>
 /// Update the gene values from the network values.
 /// </summary>
 public void UpdateGenes()
 {
     this.Genes = MatrixCODEC.NetworkToArray(this.network);
 }
 /// <summary>
 /// Convert an array of doubles to the current best network.
 /// </summary>
 /// <param name="array">The array that contains the neural network.</param>
 override public void PutArray(double[] array)
 {
     MatrixCODEC.ArrayToNetwork(array, this.network);
 }
 /// <summary>
 /// Get the network as an array of doubles.
 /// </summary>
 /// <returns>The network as an array of doubles.</returns>
 override public double[] GetArray()
 {
     return(MatrixCODEC.NetworkToArray(this.network));
 }