コード例 #1
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates the state machine configuration.
        /// </summary>
        private StateMachineSettings CreateStateMachineCfg()
        {
            //Create neural preprocessor configuration
            NeuralPreprocessorSettings neuralPreprocessorCfg = CreatePreprocessorCfg("MainRes", "MainResStruct", "AnalogPool1", "AnalogPool2");
            //Create readout layer configuration.
            //We use test data ratio = 0.1, number of regression attempts = 2 and number of attempt epochs = 1000
            ReadoutLayerSettings readoutCfg = CreateReadoutLayerCfg(0.1d, 2, 1000);
            //Create state machine configuration
            StateMachineSettings stateMachineCfg = new StateMachineSettings(neuralPreprocessorCfg, readoutCfg);

            return(stateMachineCfg);
        }
コード例 #3
0
ファイル: DemoSettings.cs プロジェクト: GrandMasterJedi/NET
            //Constructor
            public CaseSettings(XElement demoCaseElem, string dir)
            {
                Name = demoCaseElem.Attribute("name").Value;
                XElement samplesElem = demoCaseElem.Descendants("samples").First();

                FileName               = dir + "\\" + samplesElem.Attribute("fileName").Value;
                NumOfBootSamples       = (samplesElem.Attribute("bootSamples") == null) ? 0 : int.Parse(samplesElem.Attribute("bootSamples").Value);
                SingleNormalizer       = bool.Parse(samplesElem.Attribute("singleNormalizer").Value);
                NormalizerReserveRatio = double.Parse(samplesElem.Attribute("normalizerReserve").Value, CultureInfo.InvariantCulture);
                stateMachineCfg        = new StateMachineSettings(demoCaseElem.Descendants("stateMachineCfg").First());
                return;
            }
コード例 #4
0
        public static AthenaParserSetting BuildParserSetting(this StateMachineQueryContext context)
        {
            StateMachineSettings settings      = context.settings;
            AthenaParserSetting  parserSetting = new AthenaParserSetting();

            parserSetting.DefaultExportPath = settings.DefaultExportPath;
            parserSetting.DefaultTableName  = settings.DefaultTableName;
            parserSetting.Date          = settings.Date;
            parserSetting.DateFormat    = settings.DateFormat;
            parserSetting.TempDatabase  = settings.TempDatabase;
            parserSetting.TempTablePath = settings.TempTablePath;
            return(parserSetting);
        }
コード例 #5
0
ファイル: DemoSettings.cs プロジェクト: HDUfang/NET
            //Constructor
            public CaseSettings(XElement demoCaseElem, string dir)
            {
                //Parsing
                //Demo case name
                Name = demoCaseElem.Attribute("name").Value;
                //Samples
                XElement samplesElem = demoCaseElem.Descendants("samples").First();

                //Full path to csv file
                FileName = dir + "\\" + samplesElem.Attribute("fileName").Value;
                //State Machine configuration
                StateMachineCfg = new StateMachineSettings(demoCaseElem.Descendants("stateMachineCfg").First());
                return;
            }
コード例 #6
0
ファイル: TTOOForecastDesigner.cs プロジェクト: thild/NET
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create StateMachine configuration
            //Simplified input configuration
            InputEncoderSettings inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingContinuousSettings(FeedingContinuousSettings.AutoBootCyclesNum),
                                                                                true,
                                                                                new ExternalFieldSettings("High", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("Low", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("Adj Close", new RealFeatureFilterSettings())
                                                                                );
            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateForecastReadoutCfg(StateMachineDesigner.CreateSingleLayerRegrNet(new IdentitySettings(), 2, 1000),
                                                                                            0.1d,
                                                                                            1,
                                                                                            "High",
                                                                                            "Low"
                                                                                            );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure ESN fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureESNCfg(250, 1, 0, 0.2d, 0, 0.1d, 0.75d, null, PredictorsProvider.PredictorID.Activation, PredictorsProvider.PredictorID.ActivationSquare);
            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Pres Enter to continue (StateMachine training)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, ".\\Data\\TTOO.csv", out double[] predictionInputVector);

            //Forecast
            ReadoutLayer.ReadoutData readoutData = stateMachine.ComputeReadoutData(predictionInputVector);
            _log.Write("    Forecast next High and Low (real values are High=6.58$ and Low=5.99$):", false);
            _log.Write(stateMachine.RL.GetForecastReport(readoutData.DataVector, 6));
            _log.Write(string.Empty);

            return;
        }
コード例 #7
0
            //Constructor
            public CaseSettings(XElement demoCaseElem, string dir)
            {
                //Parsing
                //Demo case name
                Name = demoCaseElem.Attribute("name").Value;
                //Samples
                XElement samplesElem = demoCaseElem.Descendants("samples").First();

                //Full path to csv file
                FileName = dir + "\\" + samplesElem.Attribute("fileName").Value;
                //Normalizer reserve
                NormalizerReserveRatio = double.Parse(samplesElem.Attribute("normalizerReserve").Value, CultureInfo.InvariantCulture);
                //State Machine configuration
                StateMachineCfg = new StateMachineSettings(demoCaseElem.Descendants("stateMachineCfg").First());
                return;
            }
コード例 #8
0
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create Examples directory
            var binDir      = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var examplesDir = Path.Combine(binDir, "Examples");

            Directory.CreateDirectory(examplesDir);

            //Create StateMachine configuration
            StateMachineSettings stateMachineCfg = CreateStateMachineCfg();
            //Store StateMachine xml configuration
            string xmlConfig      = stateMachineCfg.GetXml(true).ToString();
            string configFileName = Path.Combine(examplesDir, "TTOOForecastFromScratchSMConfig.xml");

            using (StreamWriter writer = new StreamWriter(File.Create(configFileName)))
            {
                writer.Write(xmlConfig);
            }
            //Display StateMachine xml configuration
            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Press Enter to continue (StateMachine training)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, Path.Combine(binDir, "Data", "TTOO.csv"), out double[] predictionInputVector);


            //Serialize StateMachine
            string serializationFileName = Path.Combine(examplesDir, "TTOOForecastFromScratchSM.dat");

            stateMachine.Serialize(serializationFileName);

            //Forecasting
            double[] outputVector = stateMachine.Compute(predictionInputVector, out ReadoutLayer.ReadoutData readoutData);
            _log.Write("    Forecasted next High and Low TTOO prices (real prices on 2021/02/10 are High=3.61$ and Low=3.10$):", false);
            _log.Write(stateMachine.RL.GetForecastReport(outputVector, 6));
            _log.Write(string.Empty);

            //Create new StateMachine instance from the file
            //Instance was serialized before forecasting of the next values
            StateMachine stateMachineNewInstance = StateMachine.Deserialize(serializationFileName);

            //Forecasting of the deserialized instance (exactly the same results as in previous forecasting)
            outputVector = stateMachineNewInstance.Compute(predictionInputVector, out readoutData);
            _log.Write("    Forecast of the new StateMachine instance:", false);
            _log.Write(stateMachineNewInstance.RL.GetForecastReport(outputVector, 6));
            _log.Write(string.Empty);


            return;
        }
コード例 #9
0
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create StateMachine configuration
            //Simplified input configuration
            InputEncoderSettings inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, true, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped),
                                                                                false,
                                                                                new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings())
                                                                                );
            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateClassificationReadoutCfg(StateMachineDesigner.CreateSingleLayerRegrNet(new IdentitySettings(), 5, 400),
                                                                                                  0.0825d,
                                                                                                  1,
                                                                                                  "Hand movement",
                                                                                                  "curved swing",
                                                                                                  "horizontal swing",
                                                                                                  "vertical swing",
                                                                                                  "anti-clockwise arc",
                                                                                                  "clockwise arc",
                                                                                                  "circle",
                                                                                                  "horizontal straight-line",
                                                                                                  "vertical straight-line",
                                                                                                  "horizontal zigzag",
                                                                                                  "vertical zigzag",
                                                                                                  "horizontal wavy",
                                                                                                  "vertical wavy",
                                                                                                  "face-up curve",
                                                                                                  "face-down curve",
                                                                                                  "tremble"
                                                                                                  );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure ESN fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureESNCfg(150,
                                                                        0.25d,
                                                                        5,
                                                                        0.1d,
                                                                        0,
                                                                        0,
                                                                        0,
                                                                        null,
                                                                        PredictorsProvider.PredictorID.FiringCount
                                                                        );
            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Pres Enter to continue (StateMachine training and verification)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, ".\\Data\\LibrasMovement_train.csv", out _);
            _log.Write(string.Empty);
            //StateMachine verification
            _log.Write("StateMachine verification:");
            _log.Write("--------------------------");
            _log.Write(string.Empty);
            VerifyStateMachine(stateMachine, ".\\Data\\LibrasMovement_verify.csv", null, out _);
            _log.Write(string.Empty);

            return;
        }
コード例 #10
0
        //Methods
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create StateMachine configuration
            //Simplified input configuration
            InputEncoderSettings inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingContinuousSettings(FeedingContinuousSettings.AutoBootCyclesNum),
                                                                                new InputSpikesCoderSettings(),
                                                                                true,
                                                                                new ExternalFieldSettings("High", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("Low", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("Adj Close", new RealFeatureFilterSettings())
                                                                                );
            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateForecastReadoutCfg(new CrossvalidationSettings(0.1d, 0, 1),
                                                                                            StateMachineDesigner.CreateSingleLayerFFNetCfg(new AFAnalogIdentitySettings(), 2, 1000),
                                                                                            1,
                                                                                            "High",
                                                                                            "Low"
                                                                                            );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure ESN fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureESNCfg(250,  //Total size of the reservoir (number of hidden neurons within the reservoir).
                                                                        2.5,  //Maximum stimulation strength through hidden neuron's input synapses.
                                                                        1d,   //Connection density of an input field. 1 means that each input field will be synaptically connected to all neurons.
                                                                        0,    //Maximum delay on an input synapse. 0 means no delay.
                                                                        0.1d, //Interconnection density. 0.1 means that each hidden neuron will be synaptically internally connected to 10% of other hidden neurons.
                                                                        0,    //Maximum delay on an internal synapse. 0 means no delay.
                                                                        0d,   //Maximum absolute value of the hidden neuron bias. 0 means no bias.
                                                                        0d,   //Maximum retainment on an hidden neuron. 0 means no retainment.
                                                                        new PredictorsProviderSettings(new PredictorActivationSettings(),
                                                                                                       new PredictorActivationPowerSettings(2d, true),
                                                                                                       new PredictorFiringTraceSettings(0.05, 30)
                                                                                                       )
                                                                        );
            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Press Enter to continue (StateMachine training)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, "./Data/TTOO.csv", out double[] predictionInputVector);

            //Forecasting
            double[] outputVector = stateMachine.Compute(predictionInputVector, out ReadoutLayer.ReadoutData readoutData);
            _log.Write("    Forecasted next High and Low TTOO prices (real prices were High = 3.61$ and Low=3.10$):", false);
            _log.Write(stateMachine.RL.GetForecastReport(readoutData.NatDataVector, 6));
            _log.Write(string.Empty);

            return;
        }
コード例 #11
0
        //Methods
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run(InputEncoder.InputSpikesCoding spikesCoding)
        {
            //Create StateMachine configuration
            //Simplified input configuration and homogenous excitability
            InputEncoderSettings           inputCfg;
            HomogenousExcitabilitySettings homogenousExcitability;

            switch (spikesCoding)
            {
            /*
             * Horizontal coding.
             */
            case InputEncoder.InputSpikesCoding.Horizontal:
                inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, NeuralPreprocessor.BidirProcessing.Continuous, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped, new UnificationSettings(false, false)),
                                                                                                                                    //136 spiking input neurons per input field - coding at once
                                                               new InputSpikesCoderSettings(InputEncoder.InputSpikesCoding.Horizontal,
                                                                                            new A2SCoderSignalStrengthSettings(8),  //8 neurons (spike-train length = 1)
                                                                                            new A2SCoderUpDirArrowsSettings(8, 8),  //64 neurons (spike-train length = 1)
                                                                                            new A2SCoderDownDirArrowsSettings(8, 8) //64 neurons (spike-train length = 1)
                                                                                            ),
                                                               true,                                                                //Route the input pattern as the predictors to a readout layer
                                                               new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings(), true),
                                                               new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings(), true)
                                                               );
                homogenousExcitability = new HomogenousExcitabilitySettings(1d, 0.7d, 0.2d);
                break;

            /*
             * Vertical coding.
             */
            case InputEncoder.InputSpikesCoding.Vertical:
                inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, NeuralPreprocessor.BidirProcessing.Continuous, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped),
                                                                                                                                     //17 spiking input neurons per input field- coding in 10 cycles
                                                               new InputSpikesCoderSettings(InputEncoder.InputSpikesCoding.Vertical,
                                                                                            new A2SCoderSignalStrengthSettings(10),  //1 neuron (spike-train length = 10)
                                                                                            new A2SCoderUpDirArrowsSettings(8, 10),  //8 neurons (spike-train length = 10)
                                                                                            new A2SCoderDownDirArrowsSettings(8, 10) //8 neurons (spike-train length = 10)
                                                                                            ),
                                                               true,                                                                 //Route the input pattern as the predictors to a readout layer
                                                               new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings(), true),
                                                               new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings(), true)
                                                               );
                homogenousExcitability = new HomogenousExcitabilitySettings(1d, 0.7d, 0.2d);
                break;

            /*
             * Forbidden - no spikes coding.
             */
            default:
                //1 analog input neuron per input field
                inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, NeuralPreprocessor.BidirProcessing.Continuous, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped, new UnificationSettings(false, false)),
                                                               new InputSpikesCoderSettings(InputEncoder.InputSpikesCoding.Forbidden),
                                                               true,     //Route the input pattern as the predictors to a readout layer
                                                               new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings(), true),
                                                               new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings(), true)
                                                               );
                homogenousExcitability = new HomogenousExcitabilitySettings(0.25, 0.7, 0.2d);
                break;
            }

            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateClassificationReadoutCfg(new CrossvalidationSettings(0.0825d, 0, 1),
                                                                                                  StateMachineDesigner.CreateMultiLayerFFNetCfg(10, new AFAnalogLeakyReLUSettings(), 2, 5, 400),
                                                                                                  1,
                                                                                                  "Hand movement",
                                                                                                  "curved swing",
                                                                                                  "horizontal swing",
                                                                                                  "vertical swing",
                                                                                                  "anti-clockwise arc",
                                                                                                  "clockwise arc",
                                                                                                  "circle",
                                                                                                  "horizontal straight-line",
                                                                                                  "vertical straight-line",
                                                                                                  "horizontal zigzag",
                                                                                                  "vertical zigzag",
                                                                                                  "horizontal wavy",
                                                                                                  "vertical wavy",
                                                                                                  "face-up curve",
                                                                                                  "face-down curve",
                                                                                                  "tremble"
                                                                                                  );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure LSM fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureLSMCfg(272,                            //Total size of the reservoir
                                                                        new AFSpikingAdExpIFSettings(), //Activation
                                                                        homogenousExcitability,         //Homogenous excitability
                                                                        1,                              //Input connection density
                                                                        0,                              //Input max delay
                                                                        0.1d,                           //Interconnection density
                                                                        0,                              //Internal synapses max delay
                                                                        0,                              //Steady bias
                                                                        new PredictorsProviderSettings(new PredictorFiringTraceSettings(0.0005, 0))
                                                                        );

            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Press Enter to continue (StateMachine training and verification)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, "./Data/LibrasMovement_train.csv", out _);
            _log.Write(string.Empty);
            //StateMachine verification
            _log.Write("StateMachine verification:");
            _log.Write("--------------------------");
            _log.Write(string.Empty);
            VerifyStateMachine(stateMachine, "./Data/LibrasMovement_verify.csv", null, out _);
            _log.Write(string.Empty);

            return;
        }
コード例 #12
0
        //Methods
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create StateMachine configuration
            //Simplified input configuration
            InputEncoderSettings inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, NeuralPreprocessor.BidirProcessing.WithReset, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped),
                                                                                new InputSpikesCoderSettings(),
                                                                                false,
                                                                                new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings()),
                                                                                new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings())
                                                                                );
            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateClassificationReadoutCfg(new CrossvalidationSettings(0.0825d, CrossvalidationSettings.AutoFolds, 1),
                                                                                                  StateMachineDesigner.CreateSingleLayerFFNetCfg(new AFAnalogIdentitySettings(), 5, 400),
                                                                                                  1,
                                                                                                  "Hand movement",
                                                                                                  "curved swing",
                                                                                                  "horizontal swing",
                                                                                                  "vertical swing",
                                                                                                  "anti-clockwise arc",
                                                                                                  "clockwise arc",
                                                                                                  "circle",
                                                                                                  "horizontal straight-line",
                                                                                                  "vertical straight-line",
                                                                                                  "horizontal zigzag",
                                                                                                  "vertical zigzag",
                                                                                                  "horizontal wavy",
                                                                                                  "vertical wavy",
                                                                                                  "face-up curve",
                                                                                                  "face-down curve",
                                                                                                  "tremble"
                                                                                                  );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure ESN fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureESNCfg(150,                                                //Size
                                                                        StateMachineDesigner.DefaultAnalogMaxInputStrength, //Max input strength
                                                                        0.25d,                                              //Input connection density
                                                                        5,                                                  //Max input delay
                                                                        0.1d,                                               //Interconnection density
                                                                        0,                                                  //Max internal delay
                                                                        0,                                                  //Max absolute value of bias
                                                                        0,                                                  //Max retainment strength
                                                                        new PredictorsProviderSettings(new PredictorFiringTraceSettings(0.05, 45))
                                                                        );
            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Press Enter to continue (StateMachine training and verification)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, "./Data/LibrasMovement_train.csv", out _);
            _log.Write(string.Empty);
            //StateMachine verification
            _log.Write("StateMachine verification:");
            _log.Write("--------------------------");
            _log.Write(string.Empty);
            VerifyStateMachine(stateMachine, "./Data/LibrasMovement_verify.csv", null, out _);
            _log.Write(string.Empty);

            return;
        }
コード例 #13
0
        /// <summary>
        /// Runs the example code.
        /// </summary>
        public void Run()
        {
            //Create StateMachine configuration
            //Simplified input configuration
            InputEncoderSettings inputCfg = StateMachineDesigner.CreateInputCfg(new FeedingPatternedSettings(1, true, RCNet.Neural.Data.InputPattern.VariablesSchema.Groupped),
                                                                                false,
                                                                                new ExternalFieldSettings("coord_abcissa", new RealFeatureFilterSettings(), true, new SpikeCodeSettings(15, 1e-3, true, true, true, false)),
                                                                                new ExternalFieldSettings("coord_ordinate", new RealFeatureFilterSettings(), true, new SpikeCodeSettings(15, 1e-3, true, true, true, false))
                                                                                );
            //Simplified readout layer configuration
            ReadoutLayerSettings readoutCfg = StateMachineDesigner.CreateClassificationReadoutCfg(StateMachineDesigner.CreateSingleLayerRegrNet(new ElliotSettings(), 5, 400),
                                                                                                  0.0825d,
                                                                                                  1,
                                                                                                  "Hand movement",
                                                                                                  "curved swing",
                                                                                                  "horizontal swing",
                                                                                                  "vertical swing",
                                                                                                  "anti-clockwise arc",
                                                                                                  "clockwise arc",
                                                                                                  "circle",
                                                                                                  "horizontal straight-line",
                                                                                                  "vertical straight-line",
                                                                                                  "horizontal zigzag",
                                                                                                  "vertical zigzag",
                                                                                                  "horizontal wavy",
                                                                                                  "vertical wavy",
                                                                                                  "face-up curve",
                                                                                                  "face-down curve",
                                                                                                  "tremble"
                                                                                                  );
            //Create designer instance
            StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
            //Create pure LSM fashioned StateMachine configuration
            StateMachineSettings stateMachineCfg = smd.CreatePureLSMCfg(new ProportionsSettings(60, 1, 1), //Proportions (it also determines total size)
                                                                        new AdExpIFSettings(),             //Activation
                                                                                                           //new ExpIFSettings(null, null, null, null, null, null, null, 0), //Activation
                                                                        new HomogenousExcitabilitySettings(0.75, 0.75, 0.25),
                                                                        1d,                                //Input connection density
                                                                        0,                                 //Input max delay
                                                                        0.1d,                              //Interconnection density
                                                                        0,                                 //Internal synapses max delay
                                                                        0,                                 //Steady bias
                                                                        null,
                                                                        PredictorsProvider.PredictorID.FiringFadingSum
                                                                        );

            //Display StateMachine xml configuration
            string xmlConfig = stateMachineCfg.GetXml(true).ToString();

            _log.Write("StateMachine configuration xml:");
            _log.Write("-------------------------------");
            _log.Write(xmlConfig);
            _log.Write(string.Empty);
            _log.Write("Pres Enter to continue (StateMachine training and verification)...");
            _log.Write(string.Empty);
            Console.ReadLine();

            //Instantiation and training
            _log.Write("StateMachine training:");
            _log.Write("----------------------");
            _log.Write(string.Empty);
            //StateMachine instance
            StateMachine stateMachine = new StateMachine(stateMachineCfg);

            //StateMachine training
            TrainStateMachine(stateMachine, ".\\Data\\LibrasMovement_train.csv", out _);
            _log.Write(string.Empty);
            //StateMachine verification
            _log.Write("StateMachine verification:");
            _log.Write("--------------------------");
            _log.Write(string.Empty);
            VerifyStateMachine(stateMachine, ".\\Data\\LibrasMovement_verify.csv", null, out _);
            _log.Write(string.Empty);

            return;
        }