/// <summary>
        /// Generate a random training set. 
        /// </summary>
        /// <param name="seed">The seed value to use, the same seed value will always produce
        /// the same results.</param>
        /// <param name="count">How many training items to generate.</param>
        /// <param name="inputCount">How many input numbers.</param>
        /// <param name="idealCount">How many ideal numbers.</param>
        /// <param name="min">The minimum random number.</param>
        /// <param name="max">The maximum random number.</param>
        /// <returns>The random training set.</returns>
        public static BasicNeuralDataSet Generate(long seed,
                int count, int inputCount,
                int idealCount, double min, double max)
        {

            LinearCongruentialGenerator rand =
                new LinearCongruentialGenerator(seed);

            BasicNeuralDataSet result = new BasicNeuralDataSet();
            for (int i = 0; i < count; i++)
            {
                INeuralData inputData = new BasicNeuralData(inputCount);

                for (int j = 0; j < inputCount; j++)
                {
                    inputData.Data[j] = rand.Range(min, max);
                }

                INeuralData idealData = new BasicNeuralData(idealCount);

                for (int j = 0; j < idealCount; j++)
                {
                    idealData[j] = rand.Range(min, max);
                }

                BasicNeuralDataPair pair = new BasicNeuralDataPair(inputData,
                        idealData);
                result.Add(pair);

            }
            return result;
        }
        /// <summary>
        /// Create a new neural data pair object of the correct size for the neural
        /// network that is being trained. This object will be passed to the getPair
        /// method to allow the neural data pair objects to be copied to it.
        /// </summary>
        /// <param name="inputSize">The size of the input data.</param>
        /// <param name="idealSize">The size of the ideal data.</param>
        /// <returns>A new neural data pair object.</returns>
        public static INeuralDataPair CreatePair(int inputSize, int idealSize)
        {
            INeuralDataPair result;

            if (idealSize > 0)
            {
                result = new BasicNeuralDataPair(new BasicNeuralData(inputSize),
                                                 new BasicNeuralData(idealSize));
            }
            else
            {
                result = new BasicNeuralDataPair(new BasicNeuralData(inputSize));
            }

            return(result);
        }
        /// <summary>
        /// Clone this object.
        /// </summary>
        /// <returns>A clone of this object.</returns>
        public object Clone()
        {
            Object result;

            if (this.Ideal == null)
            {
                result = new BasicNeuralDataPair((INeuralData)this.input.Clone());
            }
            else
            {
                result = new BasicNeuralDataPair((INeuralData)this.input.Clone(),
                                                 (INeuralData)this.ideal.Clone());
            }

            return(result);
        }
        /// <summary>
        /// Generate the training sets.
        /// </summary>
        public virtual void Generate()
        {
            SortPoints();
            int start = CalculateStartIndex() + 1;
            int setSize = CalculateActualSetSize();
            int range = start
                        + (setSize - _predictWindowSize - _inputWindowSize);

            for (int i = start; i < range; i++)
            {
                BasicNeuralData input = GenerateInputNeuralData(i);
                BasicNeuralData ideal = GenerateOutputNeuralData(i
                                                                 + _inputWindowSize);
                var pair = new BasicNeuralDataPair(input, ideal);
                base.Add(pair);
            }
        }
        /// <summary>
        /// Handle reading an item tag.
        /// </summary>
        /// <param name="xmlIn">The XML reader.</param>
        private void HandleItem(ReadXML xmlIn)
        {
            IDictionary<String, String> properties = xmlIn.ReadPropertyBlock();
            INeuralDataPair pair = null;
            INeuralData input = new BasicNeuralData(NumberList
                   .FromList(CSVFormat.EG_FORMAT, properties
                           [BasicNeuralDataSetPersistor.TAG_INPUT]));

            if (properties.ContainsKey(BasicNeuralDataSetPersistor.TAG_IDEAL))
            {
                // supervised
                INeuralData ideal = new BasicNeuralData(NumberList
                       .FromList(CSVFormat.EG_FORMAT, properties
                               [BasicNeuralDataSetPersistor.TAG_IDEAL]));
                pair = new BasicNeuralDataPair(input, ideal);
            }
            else
            {
                // unsupervised
                pair = new BasicNeuralDataPair(input);
            }

            this.currentDataSet.Add(pair);
        }
        /// <summary>
        /// Add supervised data to the set.
        /// </summary>
        /// <param name="inputData">The input data.</param>
        /// <param name="idealData">The ideal data.</param>
        public virtual void Add(INeuralData inputData, INeuralData idealData)
        {
            INeuralDataPair pair = new BasicNeuralDataPair(inputData, idealData);

            this.data.Add(pair);
        }
        /// <summary>
        /// Add the specified data to the set.  Add unsupervised data.
        /// </summary>
        /// <param name="data1">The data to add to the set.</param>
        public virtual void Add(INeuralData data1)
        {
            INeuralDataPair pair = new BasicNeuralDataPair(data1, null);

            this.data.Add(pair);
        }
        /// <summary>
        /// Generate random training into a training set.
        /// </summary>
        /// <param name="training">The training set to generate into.</param>
        /// <param name="seed">The seed to use.</param>
        /// <param name="count">How much data to generate.</param>
        /// <param name="min">The low random value.</param>
        /// <param name="max">The high random value.</param>
        public static void Generate(INeuralDataSet training,
                long seed,
                int count,
                double min, double max)
        {

            LinearCongruentialGenerator rand
                = new LinearCongruentialGenerator(seed);

            int inputCount = training.InputSize;
            int idealCount = training.IdealSize;

            for (int i = 0; i < count; i++)
            {
                INeuralData inputData = new BasicNeuralData(inputCount);

                for (int j = 0; j < inputCount; j++)
                {
                    inputData[j] = rand.Range(min, max);
                }

                INeuralData idealData = new BasicNeuralData(idealCount);

                for (int j = 0; j < idealCount; j++)
                {
                    idealData[j] = rand.Range(min, max);
                }

                BasicNeuralDataPair pair = new BasicNeuralDataPair(inputData,
                        idealData);
                training.Add(pair);

            }
        }
Пример #9
0
 public virtual void Generate()
 {
     int num;
     int num2;
     int num3;
     int num4;
     BasicNeuralData data;
     BasicNeuralData data2;
     this.SortPoints();
     if ((((uint) num) - ((uint) num2)) <= uint.MaxValue)
     {
         goto Label_00C0;
     }
     if ((((uint) num) | 3) != 0)
     {
         goto Label_0083;
     }
     if ((((uint) num3) + ((uint) num)) <= uint.MaxValue)
     {
         goto Label_0089;
     }
     Label_0051:
     if ((((uint) num) - ((uint) num2)) < 0)
     {
         goto Label_00E8;
     }
     BasicNeuralDataPair inputData = new BasicNeuralDataPair(data, data2);
     base.Add(inputData);
     num4++;
     Label_0083:
     if (num4 >= num3)
     {
         if ((((uint) num) + ((uint) num2)) <= uint.MaxValue)
         {
             return;
         }
         goto Label_00C0;
     }
     Label_0089:
     data = this.GenerateInputNeuralData(num4);
     data2 = this.GenerateOutputNeuralData(num4 + this._xc278386c02fd6e51);
     goto Label_0051;
     Label_00C0:
     if ((((uint) num2) + ((uint) num4)) >= 0)
     {
         num = this.CalculateStartIndex() + 1;
         num2 = this.CalculateActualSetSize();
     }
     Label_00E8:
     num3 = num + ((num2 - this._xcfe8f2ba20a6a8e4) - this._xc278386c02fd6e51);
     num4 = num;
     goto Label_0083;
 }
        /// <summary>
        /// Create a new neural data pair object of the correct size for the neural
	    /// network that is being trained. This object will be passed to the getPair
	    /// method to allow the neural data pair objects to be copied to it.
        /// </summary>
        /// <param name="inputSize">The size of the input data.</param>
        /// <param name="idealSize">The size of the ideal data.</param>
        /// <returns>A new neural data pair object.</returns>
        public static INeuralDataPair CreatePair(int inputSize, int idealSize)
        {
            INeuralDataPair result;

            if (idealSize > 0)
            {
                result = new BasicNeuralDataPair(new BasicNeuralData(inputSize),
                        new BasicNeuralData(idealSize));
            }
            else
            {
                result = new BasicNeuralDataPair(new BasicNeuralData(inputSize));
            }

            return result;
        }
        /// <summary>
        /// Clone this object.
        /// </summary>
        /// <returns>A clone of this object.</returns>
        public object Clone()
        {
            Object result;

            if (this.Ideal == null)
                result = new BasicNeuralDataPair((INeuralData)this.input.Clone());
            else
                result = new BasicNeuralDataPair((INeuralData)this.input.Clone(),
                    (INeuralData)this.ideal.Clone());

            return result;
        }