Ejemplo n.º 1
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate reservoir settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing parallel perceptron settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ParallelPerceptronSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.PP.ParallelPerceptronSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement parallelPerceptronSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            NumOfGates = int.Parse(parallelPerceptronSettingsElem.Attribute("gates").Value, CultureInfo.InvariantCulture);
            Resolution = int.Parse(parallelPerceptronSettingsElem.Attribute("resolution").Value, CultureInfo.InvariantCulture);
            XElement pDeltaRuleTrainerElem = parallelPerceptronSettingsElem.Descendants("pDeltaRuleTrainer").FirstOrDefault();

            if (pDeltaRuleTrainerElem != null)
            {
                PDeltaRuleTrainerCfg = new PDeltaRuleTrainerSettings(pDeltaRuleTrainerElem);
            }
            else
            {
                PDeltaRuleTrainerCfg = new PDeltaRuleTrainerSettings();
            }
            return;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing RandomValueSettings settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public RandomValueSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RandomValue.RandomValueSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement randomValueSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Min        = double.Parse(randomValueSettingsElem.Attribute("min").Value, CultureInfo.InvariantCulture);
            Max        = double.Parse(randomValueSettingsElem.Attribute("max").Value, CultureInfo.InvariantCulture);
            RandomSign = bool.Parse(randomValueSettingsElem.Attribute("randomSign").Value);
            DistrType  = RandomClassExtensions.ParseDistributionType(randomValueSettingsElem.Attribute("distribution").Value);
            //Gaussian parameters
            GaussianDistrCfg = null;
            XElement gaussianParamsElem = randomValueSettingsElem.Descendants("gaussianDistr").FirstOrDefault();

            if (gaussianParamsElem != null)
            {
                GaussianDistrCfg = new GaussianDistrSettings(gaussianParamsElem);
            }
            return;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate reservoir settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing feed forward network settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public FeedForwardNetworkSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.FF.FeedForwardNetworkSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement feedForwardNetworkSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            OutputLayerActivation = ActivationFactory.LoadSettings(feedForwardNetworkSettingsElem.Descendants().First());
            if (!IsAllowedActivation(OutputLayerActivation, out Interval outputRange))
            {
                throw new ApplicationException($"Activation can't be used in FF network. Activation function has to be stateless and has to support derivative calculation.");
            }
            OutputRange      = outputRange;
            RegressionMethod = ParseTrainingMethodType(feedForwardNetworkSettingsElem.Attribute("regressionMethod").Value);
            //Hidden layers
            HiddenLayerCollection = new List <HiddenLayerSettings>();
            XElement hiddenLayersElem = feedForwardNetworkSettingsElem.Descendants("hiddenLayers").FirstOrDefault();

            if (hiddenLayersElem != null)
            {
                foreach (XElement layerElem in hiddenLayersElem.Descendants("layer"))
                {
                    HiddenLayerCollection.Add(new HiddenLayerSettings(layerElem));
                }
            }
            //Trainers
            LinRegrTrainerCfg = null;
            RPropTrainerCfg   = null;
            switch (RegressionMethod)
            {
            case TrainingMethodType.Linear:
                XElement linRegrTrainerElem = feedForwardNetworkSettingsElem.Descendants("linRegrTrainer").FirstOrDefault();
                if (linRegrTrainerElem != null)
                {
                    LinRegrTrainerCfg = new LinRegrTrainerSettings(linRegrTrainerElem);
                }
                else
                {
                    LinRegrTrainerCfg = new LinRegrTrainerSettings();
                }
                break;

            case TrainingMethodType.Resilient:
                XElement resPropTrainerElem = feedForwardNetworkSettingsElem.Descendants("resPropTrainer").FirstOrDefault();
                if (resPropTrainerElem != null)
                {
                    RPropTrainerCfg = new RPropTrainerSettings(resPropTrainerElem);
                }
                else
                {
                    RPropTrainerCfg = new RPropTrainerSettings();
                }
                break;
            }
            return;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing AdExpIF activation settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public AdExpIFSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.AdExpIFSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            TimeScale                         = RandomValueSettings.LoadOrDefault(activationSettingsElem, "timeScale", TypicalTimeScale);
            Resistance                        = RandomValueSettings.LoadOrDefault(activationSettingsElem, "resistance", TypicalResistance);
            RestV                             = RandomValueSettings.LoadOrDefault(activationSettingsElem, "restV", TypicalRestV);
            ResetV                            = RandomValueSettings.LoadOrDefault(activationSettingsElem, "resetV", TypicalResetV);
            RheobaseV                         = RandomValueSettings.LoadOrDefault(activationSettingsElem, "rheobaseV", TypicalRheobaseV);
            FiringThresholdV                  = RandomValueSettings.LoadOrDefault(activationSettingsElem, "firingThresholdV", TypicalFiringThresholdV);
            SharpnessDeltaT                   = RandomValueSettings.LoadOrDefault(activationSettingsElem, "sharpnessDeltaT", TypicalSharpnessDeltaT);
            AdaptationVoltageCoupling         = RandomValueSettings.LoadOrDefault(activationSettingsElem, "adaptationVoltageCoupling", TypicalAdaptationVoltageCoupling);
            AdaptationTimeConstant            = RandomValueSettings.LoadOrDefault(activationSettingsElem, "adaptationTimeConstant", TypicalAdaptationTimeConstant);
            AdaptationSpikeTriggeredIncrement = RandomValueSettings.LoadOrDefault(activationSettingsElem, "adaptationSpikeTriggeredIncrement", TypicalAdaptationSpikeTriggeredIncrement);
            SolverMethod                      = ODENumSolver.ParseComputationMethodType(activationSettingsElem.Attribute("solverMethod").Value);
            SolverCompSteps                   = int.Parse(activationSettingsElem.Attribute("solverCompSteps").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing ActivationSettings settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ActivationSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.ActivationSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            FunctionType = ActivationFactory.ParseActivationFunctionType(activationSettingsElem.Attribute("function").Value);
            Arg1         = GetArgFromXml(activationSettingsElem, 1);
            Arg2         = GetArgFromXml(activationSettingsElem, 2);
            Arg3         = GetArgFromXml(activationSettingsElem, 3);
            Arg4         = GetArgFromXml(activationSettingsElem, 4);
            Arg5         = GetArgFromXml(activationSettingsElem, 5);
            Arg6         = GetArgFromXml(activationSettingsElem, 6);
            Arg7         = GetArgFromXml(activationSettingsElem, 7);
            Arg8         = GetArgFromXml(activationSettingsElem, 8);
            Arg9         = GetArgFromXml(activationSettingsElem, 9);
            Arg10        = GetArgFromXml(activationSettingsElem, 10);
            Arg11        = GetArgFromXml(activationSettingsElem, 11);
            Arg12        = GetArgFromXml(activationSettingsElem, 12);
            Arg13        = GetArgFromXml(activationSettingsElem, 13);
            Arg14        = GetArgFromXml(activationSettingsElem, 14);
            Arg15        = GetArgFromXml(activationSettingsElem, 15);
            return;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// This is the preferred way to instantiate ReadoutLayer settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing ReadoutLayer settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ReadoutLayerSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.ReadoutLayerSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement readoutLayerSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            TestDataRatio = double.Parse(readoutLayerSettingsElem.Attribute("testDataRatio").Value, CultureInfo.InvariantCulture);
            NumOfFolds    = readoutLayerSettingsElem.Attribute("folds").Value == "Auto" ? 0 : int.Parse(readoutLayerSettingsElem.Attribute("folds").Value);
            //Readout unit
            XElement readoutUnitElem = readoutLayerSettingsElem.Descendants("readoutUnit").First();

            ReadoutUnitCfg = new ReadoutUnitSettings(readoutUnitElem);
            //Output fields
            XElement outputFieldsElem = readoutLayerSettingsElem.Descendants("outputFields").First();

            OutputFieldNameCollection = new List <string>();
            foreach (XElement outputFieldElem in outputFieldsElem.Descendants("field"))
            {
                OutputFieldNameCollection.Add(outputFieldElem.Attribute("name").Value);
            }
            return;
        }
Ejemplo n.º 7
0
            /// <summary>
            /// Creates the instance and initialize it from given xml element.
            /// </summary>
            /// <param name="elem">
            /// Xml data containing settings.
            /// Content of xml element is always validated against the xml schema.
            /// </param>
            public InterconnectionSettings(XElement elem)
            {
                //Validation
                ElemValidator validator     = new ElemValidator();
                Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

                validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Preprocessing.PoolInterconnectionSettings.xsd");
                validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
                XElement settingsElem = validator.Validate(elem, "rootElem");

                //Parsing
                //Density
                Density = double.Parse(settingsElem.Attribute("density").Value, CultureInfo.InvariantCulture);
                //Ratios
                double relShareEE = double.Parse(settingsElem.Attribute("relShareEE").Value, CultureInfo.InvariantCulture);
                double relShareEI = double.Parse(settingsElem.Attribute("relShareEI").Value, CultureInfo.InvariantCulture);
                double relShareIE = double.Parse(settingsElem.Attribute("relShareIE").Value, CultureInfo.InvariantCulture);
                double relShareII = double.Parse(settingsElem.Attribute("relShareII").Value, CultureInfo.InvariantCulture);
                double sum        = relShareEE + relShareEI + relShareIE + relShareII;

                RatioEE = relShareEE / sum;
                RatioEI = relShareEI / sum;
                RatioIE = relShareIE / sum;
                RatioII = relShareII / sum;
                //Average distance
                AvgDistance = settingsElem.Attribute("avgDistance").Value == "NA" ? 0d : double.Parse(settingsElem.Attribute("avgDistance").Value, CultureInfo.InvariantCulture);
                //Allow self connections?
                AllowSelfConnection = bool.Parse(settingsElem.Attribute("allowSelfConnection").Value);
                //Will have each neuron the same number of connections?
                ConstantNumOfConnections = bool.Parse(settingsElem.Attribute("constantNumOfConnections").Value);
                //Synapse
                SynapseCfg = new InternalSynapseSettings(settingsElem.Descendants("synapse").First());
                return;
            }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate reservoir settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing reservoir settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ReservoirSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.ReservoirSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement reservoirSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            SettingsName   = reservoirSettingsElem.Attribute("name").Value;
            InputCoding    = CommonEnums.ParseInputCodingType(reservoirSettingsElem.Attribute("inputCoding").Value);
            InputDuration  = int.Parse(reservoirSettingsElem.Attribute("inputDuration").Value, CultureInfo.InvariantCulture);
            SpectralRadius = reservoirSettingsElem.Attribute("spectralRadius").Value == "NA" ? -1d : double.Parse(reservoirSettingsElem.Attribute("spectralRadius").Value, CultureInfo.InvariantCulture);
            //Pool settings collection
            PoolSettingsCollection = new List <PoolSettings>();
            foreach (XElement poolSettingsElem in reservoirSettingsElem.Descendants("pools").First().Descendants("pool"))
            {
                PoolSettingsCollection.Add(new PoolSettings(poolSettingsElem));
            }
            //Pools interconnection settings
            PoolsInterconnectionCollection = new List <PoolsInterconnection>();
            XElement pool2PoolConnContainerElem = reservoirSettingsElem.Descendants("pool2PoolConns").FirstOrDefault();

            if (pool2PoolConnContainerElem != null)
            {
                foreach (XElement poolsInterConnElem in pool2PoolConnContainerElem.Descendants("pool2PoolConn"))
                {
                    PoolsInterconnectionCollection.Add(new PoolsInterconnection(poolsInterConnElem, PoolSettingsCollection));
                }
            }
            return;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml element containing the settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public HiddenNeuronPredictorsSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Neuron.HiddenNeuronPredictorsSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement predictorsElem = validator.Validate(elem, "rootElem");

            //Parsing of params
            Params = null;
            XElement paramsElem = predictorsElem.Descendants("settings").FirstOrDefault();

            if (paramsElem != null)
            {
                Params = new Settings(paramsElem);
            }
            //Parsing of permits
            XElement permitElem = predictorsElem.Descendants("permission").First();

            Activation             = bool.Parse(permitElem.Attribute("activation").Value);
            SquaredActivation      = bool.Parse(permitElem.Attribute("squaredActivation").Value);
            FiringExpWRate         = bool.Parse(permitElem.Attribute("firingExpWRate").Value);
            FiringFadingSum        = bool.Parse(permitElem.Attribute("firingFadingSum").Value);
            FiringCount            = bool.Parse(permitElem.Attribute("firingCount").Value);
            FiringBinPattern       = bool.Parse(permitElem.Attribute("firingBinPattern").Value);
            NumOfEnabledPredictors = GetNumOfEnabledPredictors();
            return;
        }
Ejemplo n.º 10
0
            /// <summary>
            /// Creates the instance and initialize it from given xml element.
            /// </summary>
            /// <param name="elem">
            /// Xml data containing settings.
            /// Content of xml element is always validated against the xml schema.
            /// </param>
            public NeuronGroupSettings(XElement elem)
            {
                //Validation
                ElemValidator validator     = new ElemValidator();
                Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

                validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Preprocessing.PoolNeuronGroupSettings.xsd");
                validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
                XElement settingsElem = validator.Validate(elem, "rootElem");

                //Parsing
                //Name
                Name = settingsElem.Attribute("name").Value;
                //Role
                Role = CommonEnums.ParseNeuronRole(settingsElem.Attribute("role").Value);
                //Relative share
                RelativeShare = double.Parse(settingsElem.Attribute("relShare").Value, CultureInfo.InvariantCulture);
                //Augmented states
                AugmentedStates = bool.Parse(settingsElem.Attribute("augmentedStates").Value);
                //Activation settings
                ActivationCfg = ActivationFactory.LoadSettings(settingsElem.Descendants().First());
                //Bias
                BiasCfg = new RandomValueSettings(settingsElem.Descendants("bias").First());
                return;
            }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public FeedForwardNetworkSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.FF.FeedForwardNetworkSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            OutputLayerActivation = ActivationFactory.LoadSettings(settingsElem.Descendants().First());
            if (!IsAllowedActivation(OutputLayerActivation, out Interval outputRange))
            {
                throw new ApplicationException($"Activation can't be used in FF network. Activation function has to be stateless and has to support derivative calculation.");
            }
            OutputRange = outputRange;
            //Hidden layers
            HiddenLayerCollection = new List <HiddenLayerSettings>();
            XElement hiddenLayersElem = settingsElem.Descendants("hiddenLayers").FirstOrDefault();

            if (hiddenLayersElem != null)
            {
                foreach (XElement layerElem in hiddenLayersElem.Descendants("layer"))
                {
                    HiddenLayerCollection.Add(new HiddenLayerSettings(layerElem));
                }
            }
            //Trainer configuration
            TrainerCfg = null;
            foreach (XElement candidate in settingsElem.Descendants())
            {
                if (candidate.Name.LocalName == "linRegrTrainer")
                {
                    TrainerCfg = new LinRegrTrainerSettings(candidate);
                }
                else if (candidate.Name.LocalName == "qrdRegrTrainer")
                {
                    TrainerCfg = new QRDRegrTrainerSettings(candidate);
                }
                else if (candidate.Name.LocalName == "ridgeRegrTrainer")
                {
                    TrainerCfg = new RidgeRegrTrainerSettings(candidate);
                }
                else if (candidate.Name.LocalName == "resPropTrainer")
                {
                    TrainerCfg = new RPropTrainerSettings(candidate);
                }
                if (TrainerCfg != null)
                {
                    break;
                }
            }
            if (TrainerCfg == null)
            {
                throw new Exception("Trainer settings not found.");
            }
            return;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public InputSynapseSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Synapse.InputSynapseSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");
            //Parsing
            XElement cfgElem;

            //Spiking target
            //Scope
            cfgElem = settingsElem.XPathSelectElement("./spikingTarget");
            if (cfgElem != null)
            {
                SpikingTargetScope = BaseSynapse.ParseSynapticTargetScope(cfgElem.Attribute("scope").Value);
            }
            else
            {
                SpikingTargetScope = BaseSynapse.SynapticTargetScope.Excitatory;
            }
            //Spiking target Weight
            cfgElem = settingsElem.XPathSelectElement("./spikingTarget/weight");
            if (cfgElem != null)
            {
                SpikingTargetWeightCfg = new RandomValueSettings(cfgElem);
            }
            else
            {
                SpikingTargetWeightCfg = new RandomValueSettings(0, 1);
            }
            //Analog target
            //Scope
            cfgElem = settingsElem.XPathSelectElement("./analogTarget");
            if (cfgElem != null)
            {
                AnalogTargetScope = BaseSynapse.ParseSynapticTargetScope(cfgElem.Attribute("scope").Value);
            }
            else
            {
                AnalogTargetScope = BaseSynapse.SynapticTargetScope.All;
            }
            //Analog target Weight
            cfgElem = settingsElem.XPathSelectElement("./analogTarget/weight");
            if (cfgElem != null)
            {
                AnalogTargetWeightCfg = new RandomValueSettings(cfgElem);
            }
            else
            {
                AnalogTargetWeightCfg = new RandomValueSettings(0, 1);
            }
            //Delay
            DelayMethod = BaseSynapse.ParseSynapticDelayMethod(settingsElem.Attribute("delayMethod").Value);
            MaxDelay    = int.Parse(settingsElem.Attribute("maxDelay").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing RandomValueSettings settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public RandomValueSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RandomValue.RandomValueSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement randomValueSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Min        = double.Parse(randomValueSettingsElem.Attribute("min").Value, CultureInfo.InvariantCulture);
            Max        = double.Parse(randomValueSettingsElem.Attribute("max").Value, CultureInfo.InvariantCulture);
            RandomSign = bool.Parse(randomValueSettingsElem.Attribute("randomSign").Value);
            XElement distrParamsElem = randomValueSettingsElem.Elements().FirstOrDefault();

            if (distrParamsElem == null)
            {
                DistrType = RandomExtensions.DistributionType.Uniform;
                DistrCfg  = new UniformDistrSettings();
            }
            else
            {
                switch (distrParamsElem.Name.LocalName)
                {
                case "uniformDistr":
                    DistrType = RandomExtensions.DistributionType.Uniform;
                    DistrCfg  = new UniformDistrSettings(distrParamsElem);
                    break;

                case "gaussianDistr":
                    DistrType = RandomExtensions.DistributionType.Gaussian;
                    DistrCfg  = new GaussianDistrSettings(distrParamsElem);
                    break;

                case "exponentialDistr":
                    DistrType = RandomExtensions.DistributionType.Exponential;
                    DistrCfg  = new ExponentialDistrSettings(distrParamsElem);
                    break;

                case "gammaDistr":
                    DistrType = RandomExtensions.DistributionType.Gamma;
                    DistrCfg  = new GammaDistrSettings(distrParamsElem);
                    break;

                default:
                    throw new Exception($"Unexpected element {distrParamsElem.Name.LocalName}");
                }
            }
            Check();
            return;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public BinFeatureFilterSettings(XElement elem)
            : base(BaseFeatureFilter.FeatureType.Binary)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Filter.BinFeatureFilterSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            return;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing Sigmoid activation settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public SigmoidSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.SigmoidSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            return;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public ConstGeneratorSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Generators.ConstGeneratorSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            ConstSignal = double.Parse(settingsElem.Attribute("constSignal").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing SoftExponential activation settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public SoftExponentialSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.SoftExponentialSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Alpha = RandomValueSettings.LoadOrDefault(activationSettingsElem, "alpha", TypicalAlpha);
            return;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing LeakyReLU activation settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public LeakyReLUSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.LeakyReLUSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            NegSlope = RandomValueSettings.LoadOrDefault(activationSettingsElem, "negSlope", TypicalNegSlope);
            return;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing ISRU activation settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ISRUSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Activation.ISRUSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement activationSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Alpha = new RandomValueSettings(activationSettingsElem.Descendants("alpha").FirstOrDefault());
            return;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public StaticSynapseSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Synapse.StaticSynapseSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            //Weight
            WeightCfg = new RandomValueSettings(settingsElem.Descendants("weight").First());
            return;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public EnumFeatureFilterSettings(XElement elem)
            : base(BaseFeatureFilter.FeatureType.Enum)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Filter.EnumFeatureFilterSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            NumOfElements = int.Parse(settingsElem.Attribute("numOfElements").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing linear regression trainer settings</param>
        public RidgeRegrTrainerSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.FF.RidgeRegrTrainerSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            NumOfAttemptEpochs = int.Parse(settingsElem.Attribute("attemptEpochs").Value, CultureInfo.InvariantCulture);
            LambdaSeekerCfg    = new ParamSeekerSettings(settingsElem.Descendants("lambda").First());
            return;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public PulseGeneratorSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Generators.PulseGeneratorSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Signal    = double.Parse(settingsElem.Attribute("signal").Value, CultureInfo.InvariantCulture);
            AvgPeriod = Math.Abs(double.Parse(settingsElem.Attribute("avgPeriod").Value, CultureInfo.InvariantCulture));
            Mode      = ParseTimingMode(settingsElem.Attribute("mode").Value);
            return;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing elastic linear regression trainer settings</param>
        public ElasticRegrTrainerSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.FF.ElasticRegrTrainerSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            NumOfAttemptEpochs = int.Parse(settingsElem.Attribute("attemptEpochs").Value, CultureInfo.InvariantCulture);
            Lambda             = double.Parse(settingsElem.Attribute("lambda").Value, CultureInfo.InvariantCulture);
            Alpha = double.Parse(settingsElem.Attribute("alpha").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing the settings</param>
        public ParamSeekerSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.MathTools.PS.ParamSeekerSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement linRegrTrainerSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Min        = double.Parse(linRegrTrainerSettingsElem.Attribute("min").Value, CultureInfo.InvariantCulture);
            Max        = double.Parse(linRegrTrainerSettingsElem.Attribute("max").Value, CultureInfo.InvariantCulture);
            NumOfSteps = int.Parse(linRegrTrainerSettingsElem.Attribute("steps").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public RealFeatureFilterSettings(XElement elem)
            : base(BaseFeatureFilter.FeatureType.Real)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Filter.RealFeatureFilterSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Standardize = bool.Parse(settingsElem.Attribute("standardize").Value);
            KeepReserve = bool.Parse(settingsElem.Attribute("keepReserve").Value);
            return;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing settings</param>
        public SinusoidalGeneratorSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Data.Generators.SinusoidalGeneratorSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement settingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Phase = double.Parse(settingsElem.Attribute("phase").Value, CultureInfo.InvariantCulture);
            Freq  = double.Parse(settingsElem.Attribute("freq").Value, CultureInfo.InvariantCulture);
            Ampl  = double.Parse(settingsElem.Attribute("ampl").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// Content of xml element is always validated against the xml schema.
        /// </summary>
        /// <param name="elem">Xml data containing linear regression trainer settings</param>
        public LinRegrTrainerSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.FF.LinRegrTrainerSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement linRegrTrainerSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            HiNoiseIntensity = double.Parse(linRegrTrainerSettingsElem.Attribute("hiNoiseIntensity").Value, CultureInfo.InvariantCulture);
            MaxStretch       = double.Parse(linRegrTrainerSettingsElem.Attribute("maxStretch").Value, CultureInfo.InvariantCulture);
            ZeroMargin       = double.Parse(linRegrTrainerSettingsElem.Attribute("zeroMargin").Value, CultureInfo.InvariantCulture);
            return;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate reservoir settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing reservoir settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public ReservoirSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Preprocessing.ReservoirSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement reservoirSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            SettingsName        = reservoirSettingsElem.Attribute("name").Value;
            SynapticDelayMethod = CommonEnums.ParseSynapticDelayMethod(reservoirSettingsElem.Attribute("synapticDelayMethod").Value);
            MaxInputDelay       = int.Parse(reservoirSettingsElem.Attribute("maxInputDelay").Value, CultureInfo.InvariantCulture);
            MaxInternalDelay    = int.Parse(reservoirSettingsElem.Attribute("maxInternalDelay").Value, CultureInfo.InvariantCulture);
            SpectralRadius      = reservoirSettingsElem.Attribute("spectralRadius").Value == "NA" ? -1d : double.Parse(reservoirSettingsElem.Attribute("spectralRadius").Value, CultureInfo.InvariantCulture);
            //Input entry point
            InputEntryPoint = new int[3];
            if (reservoirSettingsElem.Descendants("inputEntryPoint").Count() > 0)
            {
                InputEntryPoint[0] = int.Parse(reservoirSettingsElem.Descendants("inputEntryPoint").First().Attribute("x").Value, CultureInfo.InvariantCulture);
                InputEntryPoint[1] = int.Parse(reservoirSettingsElem.Descendants("inputEntryPoint").First().Attribute("y").Value, CultureInfo.InvariantCulture);
                InputEntryPoint[2] = int.Parse(reservoirSettingsElem.Descendants("inputEntryPoint").First().Attribute("z").Value, CultureInfo.InvariantCulture);
            }
            else
            {
                InputEntryPoint.Populate(0);
            }
            //Pool settings collection
            PoolSettingsCollection = new List <PoolSettings>();
            foreach (XElement poolSettingsElem in reservoirSettingsElem.Descendants("pools").First().Descendants("pool"))
            {
                PoolSettingsCollection.Add(new PoolSettings(poolSettingsElem));
            }
            //Pools interconnection settings
            PoolsInterconnectionCollection = new List <PoolsInterconnection>();
            XElement pool2PoolConnContainerElem = reservoirSettingsElem.Descendants("pool2PoolConns").FirstOrDefault();

            if (pool2PoolConnContainerElem != null)
            {
                foreach (XElement poolsInterConnElem in pool2PoolConnContainerElem.Descendants("pool2PoolConn"))
                {
                    PoolsInterconnectionCollection.Add(new PoolsInterconnection(poolsInterConnElem, PoolSettingsCollection));
                }
            }
            return;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates an instance and initializes it from given xml element.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing RandomValueSettings settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public RandomValueSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RandomValue.RandomValueSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement randomValueSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            Min        = double.Parse(randomValueSettingsElem.Attribute("min").Value, CultureInfo.InvariantCulture);
            Max        = double.Parse(randomValueSettingsElem.Attribute("max").Value, CultureInfo.InvariantCulture);
            RandomSign = bool.Parse(randomValueSettingsElem.Attribute("randomSign").Value);
            DistrType  = RandomClassExtensions.ParseDistributionType(randomValueSettingsElem.Attribute("distribution").Value);
            return;
        }