コード例 #1
0
ファイル: QRDRegrTrainerSettings.cs プロジェクト: lulzzz/NET
 /// <summary>
 /// Deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public QRDRegrTrainerSettings(QRDRegrTrainerSettings source)
 {
     NumOfAttempts      = source.NumOfAttempts;
     NumOfAttemptEpochs = source.NumOfAttemptEpochs;
     NoiseZeroMargin    = source.NoiseZeroMargin;
     MaxNoiseSeekerCfg  = source.MaxNoiseSeekerCfg.DeepClone();
     return;
 }
コード例 #2
0
 //Constructor
 /// <summary>
 /// Constructs an initialized instance
 /// </summary>
 /// <param name="net">FF network to be trained</param>
 /// <param name="inputVectorCollection">Predictors (input)</param>
 /// <param name="outputVectorCollection">Ideal outputs (the same number of rows as number of inputs)</param>
 /// <param name="rand">Random object to be used for adding a white-noise to predictors</param>
 /// <param name="settings">Startup parameters of the trainer</param>
 public QRDRegrTrainer(FeedForwardNetwork net,
                       List <double[]> inputVectorCollection,
                       List <double[]> outputVectorCollection,
                       QRDRegrTrainerSettings settings,
                       Random rand
                       )
 {
     //Check network readyness
     if (!net.Finalized)
     {
         throw new Exception("Can´t create trainer. Network structure was not finalized.");
     }
     //Check network conditions
     if (net.LayerCollection.Count != 1 || !(net.LayerCollection[0].Activation is Identity))
     {
         throw new Exception("Can´t create trainer. Network structure is not complient (single layer having Identity activation).");
     }
     //Check samples conditions
     if (inputVectorCollection.Count < inputVectorCollection[0].Length + 1)
     {
         throw new Exception($"Can´t create trainer. Insufficient number of training samples {inputVectorCollection.Count}. Minimum is {(inputVectorCollection[0].Length + 1)}.");
     }
     //Parameters
     _settings                        = settings;
     MaxAttempt                       = _settings.NumOfAttempts;
     MaxAttemptEpoch                  = _settings.NumOfAttemptEpochs;
     _net                             = net;
     _rand                            = rand;
     _inputVectorCollection           = inputVectorCollection;
     _outputVectorCollection          = outputVectorCollection;
     _outputSingleColMatrixCollection = new List <Matrix>(_net.NumOfOutputValues);
     for (int outputIdx = 0; outputIdx < _net.NumOfOutputValues; outputIdx++)
     {
         Matrix outputSingleColMatrix = new Matrix(_outputVectorCollection.Count, 1);
         for (int row = 0; row < _outputVectorCollection.Count; row++)
         {
             //Output
             outputSingleColMatrix.Data[row][0] = _outputVectorCollection[row][outputIdx];
         }
         _outputSingleColMatrixCollection.Add(outputSingleColMatrix);
     }
     //Start training attempt
     Attempt = 0;
     NextAttempt();
     return;
 }
コード例 #3
0
ファイル: QRDRegrTrainerSettings.cs プロジェクト: lulzzz/NET
        //Methods
        /// <summary>
        /// See the base.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            QRDRegrTrainerSettings cmpSettings = obj as QRDRegrTrainerSettings;

            if (NumOfAttempts != cmpSettings.NumOfAttempts ||
                NumOfAttemptEpochs != cmpSettings.NumOfAttemptEpochs ||
                NoiseZeroMargin != cmpSettings.NoiseZeroMargin ||
                !Equals(MaxNoiseSeekerCfg, cmpSettings.MaxNoiseSeekerCfg)
                )
            {
                return(false);
            }
            return(true);
        }