예제 #1
0
 //Methods
 /// <inheritdoc/>
 protected override void Check()
 {
     if (BootCycles != AutoBootCyclesNum && BootCycles <= 0)
     {
         throw new ArgumentException($"Invalid BootCycles {BootCycles.ToString(CultureInfo.InvariantCulture)}. BootCycles must be equal to {AutoBootCyclesNum.ToString(CultureInfo.InvariantCulture)} for automatic boot cycles or GT 0.", "BootCycles");
     }
     return;
 }
예제 #2
0
        /// <inheritdoc/>
        public override XElement GetXml(string rootElemName, bool suppressDefaults)
        {
            XElement rootElem = new XElement(rootElemName);

            if (!suppressDefaults || !IsDefaultBootCycles)
            {
                rootElem.Add(new XAttribute("bootCycles", BootCycles == AutoBootCyclesNum ? AutoBootCyclesCode : BootCycles.ToString(CultureInfo.InvariantCulture)));
            }
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
예제 #3
0
        /// <summary>
        /// Initializes the preprocessor, preprocess the specified data bundle and returns the predictors together with the ideal values.
        /// </summary>
        /// <param name="inputBundle">The data bundle to be preprocessed.</param>
        /// <param name="preprocessingOverview">The statistics and other important information related to data preprocessing.</param>
        public VectorBundle InitializeAndPreprocessBundle(VectorBundle inputBundle, out PreprocessingOverview preprocessingOverview)
        {
            //Check amount of input data
            if (BootCycles > 0 && inputBundle.InputVectorCollection.Count <= BootCycles)
            {
                throw new InvalidOperationException($"Insufficient number of input data instances. The number of instances must be greater than the number of boot cycles ({BootCycles.ToString(CultureInfo.InvariantCulture)}).");
            }
            //Reset reservoirs
            ResetReservoirs(true);
            //Reset input encoder and initialize its feature filters
            _inputEncoder.Initialize(inputBundle);
            //Initialize output features descriptors
            InitPredictorsDescriptors();
            //Allocate output bundle
            VectorBundle outputBundle = new VectorBundle(inputBundle.InputVectorCollection.Count);

            //Process data
            //Collect predictors
            for (int dataSetIdx = 0; dataSetIdx < inputBundle.InputVectorCollection.Count; dataSetIdx++)
            {
                bool readyToCollect = dataSetIdx >= BootCycles || _preprocessorCfg.InputEncoderCfg.FeedingCfg.FeedingType == InputEncoder.InputFeedingType.Patterned;
                //Push input data into the network
                double[] outputFeatures = PushExtInputVector(inputBundle.InputVectorCollection[dataSetIdx], readyToCollect);
                //Collect output features?
                if (readyToCollect)
                {
                    //Predictors
                    outputBundle.InputVectorCollection.Add(outputFeatures);
                    //Desired outputs
                    outputBundle.OutputVectorCollection.Add(inputBundle.OutputVectorCollection[dataSetIdx]);
                }
                //Raise informative event
                PreprocessingProgressChanged?.Invoke(inputBundle.InputVectorCollection.Count, dataSetIdx + 1, null);
            }
            //Initialize output features switches
            InitOutputFeaturesGeneralSwitches(outputBundle.InputVectorCollection);
            //Buld preprocessing overview
            preprocessingOverview = new PreprocessingOverview(CollectStatatistics(),
                                                              TotalNumOfHiddenNeurons,
                                                              PredictorDescriptorCollection.Count,
                                                              NumOfSuppressedPredictors,
                                                              NumOfActivePredictors
                                                              );
            //Raise final informative event
            PreprocessingProgressChanged(inputBundle.InputVectorCollection.Count, inputBundle.InputVectorCollection.Count, preprocessingOverview);
            //Return output
            return(outputBundle);
        }