Esempio n. 1
0
 /// <summary>
 /// The deep copy constructor.
 /// </summary>
 /// <param name="source">The source instance.</param>
 public QRDRegrTrainerSettings(QRDRegrTrainerSettings source)
 {
     NumOfAttempts      = source.NumOfAttempts;
     NumOfAttemptEpochs = source.NumOfAttemptEpochs;
     NoiseZeroMargin    = source.NoiseZeroMargin;
     NoiseFinderCfg     = (ParamValFinderSettings)source.NoiseFinderCfg.DeepClone();
     return;
 }
Esempio n. 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 InvalidOperationException($"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 InvalidOperationException($"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 InvalidOperationException($"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;
 }