Exemplo n.º 1
0
 //Constructor
 /// <summary>
 /// Constructs an instance of State Machine
 /// </summary>
 /// <param name="settings">State Machine settings</param>
 /// <param name="inputRange">Range of input values</param>
 public StateMachine(StateMachineSettings settings, Interval inputRange)
 {
     _settings = settings.DeepClone();
     //Random object
     if (_settings.RandomizerSeek < 0)
     {
         _rand = new System.Random();
     }
     else
     {
         _rand = new System.Random(_settings.RandomizerSeek);
     }
     //Build structure
     //Reservoir instance(s)
     _numOfPredictors             = 0;
     _reservoirInstanceCollection = new List <ReservoirInstance>(_settings.ReservoirInstanceDefinitionCollection.Count);
     foreach (StateMachineSettings.ReservoirInstanceDefinition instanceDefinition in _settings.ReservoirInstanceDefinitionCollection)
     {
         ReservoirInstance reservoirInstance = new ReservoirInstance(instanceDefinition, _settings.RandomizerSeek, inputRange);
         _reservoirInstanceCollection.Add(reservoirInstance);
         _numOfPredictors += reservoirInstance.ReservoirObj.NumOfOutputPredictors;
     }
     if (_settings.RouteInputToReadout)
     {
         _numOfPredictors += _settings.InputFieldNameCollection.Count;
     }
     //Readout layer
     _readoutLayer = new ReadoutLayer(_settings.TaskType, _settings.ReadoutLayerConfig, _rand);
     return;
 }
Exemplo n.º 2
0
        //Constructor
        /// <summary>
        /// Creates an initialized instance.
        /// </summary>
        /// <param name="preprocessorCfg">The configuration of the neural preprocessor.</param>
        /// <param name="randomizerSeek">The random number generator initial seek.</param>
        public NeuralPreprocessor(NeuralPreprocessorSettings preprocessorCfg, int randomizerSeek)
        {
            _preprocessorCfg        = (NeuralPreprocessorSettings)preprocessorCfg.DeepClone();
            TotalNumOfHiddenNeurons = 0;
            ///////////////////////////////////////////////////////////////////////////////////
            //Input encoder
            _inputEncoder = new InputEncoder(_preprocessorCfg.InputEncoderCfg);
            ///////////////////////////////////////////////////////////////////////////////////
            //Reservoir instance(s)
            BootCycles = 0;
            //Random generator used for reservoir structure initialization
            Random rand = (randomizerSeek < 0 ? new Random() : new Random(randomizerSeek));

            ReservoirCollection = new List <ReservoirInstance>(_preprocessorCfg.ReservoirInstancesCfg.ReservoirInstanceCfgCollection.Count);
            int reservoirInstanceID = 0;
            int defaultBootCycles   = 0;

            foreach (ReservoirInstanceSettings reservoirInstanceCfg in _preprocessorCfg.ReservoirInstancesCfg.ReservoirInstanceCfgCollection)
            {
                ReservoirStructureSettings structCfg = _preprocessorCfg.ReservoirStructuresCfg.GetReservoirStructureCfg(reservoirInstanceCfg.StructureCfgName);
                ReservoirInstance          reservoir = new ReservoirInstance(reservoirInstanceID++,
                                                                             structCfg,
                                                                             reservoirInstanceCfg,
                                                                             _inputEncoder,
                                                                             rand
                                                                             );
                ReservoirCollection.Add(reservoir);
                TotalNumOfHiddenNeurons += reservoir.Size;
                defaultBootCycles        = Math.Max(defaultBootCycles, reservoir.GetDefaultBootCycles());
            }
            //Boot cycles setup
            if (_preprocessorCfg.InputEncoderCfg.FeedingCfg.FeedingType == InputEncoder.InputFeedingType.Continuous)
            {
                FeedingContinuousSettings feedingCfg = (FeedingContinuousSettings)preprocessorCfg.InputEncoderCfg.FeedingCfg;
                BootCycles = feedingCfg.BootCycles == FeedingContinuousSettings.AutoBootCyclesNum ? defaultBootCycles : feedingCfg.BootCycles;
            }
            else
            {
                BootCycles = 0;
            }
            //Output features
            _totalNumOfReservoirsPredictors      = 0;
            _predictorsTimePointSlicesPlan       = null;
            PredictorDescriptorCollection        = null;
            OutputFeatureGeneralSwitchCollection = null;
            NumOfActivePredictors = 0;
            return;
        }