/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("name", Name), new XAttribute("relShare", RelShare.ToString(CultureInfo.InvariantCulture)), ActivationCfg.GetXml(suppressDefaults) ); if (!suppressDefaults || !IsDefaultFiringThreshold) { rootElem.Add(new XAttribute("firingThreshold", FiringThreshold.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultThresholdMaxRefDeepness) { rootElem.Add(new XAttribute("thresholdMaxRefDeepness", ThresholdMaxRefDeepness.ToString(CultureInfo.InvariantCulture))); } if (BiasCfg != null) { rootElem.Add(BiasCfg.GetXml("bias", suppressDefaults)); } if (RetainmentCfg != null) { rootElem.Add(RetainmentCfg.GetXml(suppressDefaults)); } rootElem.Add(PredictorsCfg.GetXml(suppressDefaults)); Validate(rootElem, XsdTypeName); return(rootElem); }
//Methods /// <inheritdoc/> protected override void Check() { if (Name.Length == 0) { throw new ArgumentException($"Name can not be empty.", "Name"); } Type activationType = ActivationCfg.GetType(); if (activationType != typeof(AFAnalogSQNLSettings) && activationType != typeof(AFAnalogElliotSettings) && activationType != typeof(AFAnalogGaussianSettings) && activationType != typeof(AFAnalogISRUSettings) && activationType != typeof(AFAnalogSigmoidSettings) && activationType != typeof(AFAnalogSincSettings) && activationType != typeof(AFAnalogSinusoidSettings) && activationType != typeof(AFAnalogTanHSettings) ) { throw new ArgumentException($"Not allowed Activation settings {activationType.Name}.", "ActivationCfg"); } if (FiringThreshold < 0 || FiringThreshold > 1) { throw new ArgumentException($"Invalid FiringThreshold {FiringThreshold.ToString(CultureInfo.InvariantCulture)}. FiringThreshold must be GE to 0 and LE to 1.", "FiringThreshold"); } if (ThresholdMaxRefDeepness < 1) { throw new ArgumentException($"Invalid ThresholdMaxRefDeepness {ThresholdMaxRefDeepness.ToString(CultureInfo.InvariantCulture)}. ThresholdMaxRefDeepness must be GT 1.", "ThresholdMaxRefDeepness"); } return; }
//Methods /// <summary> /// Checks consistency /// </summary> protected override void Check() { if (Name.Length == 0) { throw new ArgumentException($"Name can not be empty.", "Name"); } Type activationType = ActivationCfg.GetType(); if (activationType != typeof(SimpleIFSettings) && activationType != typeof(LeakyIFSettings) && activationType != typeof(ExpIFSettings) && activationType != typeof(AdExpIFSettings) && activationType != typeof(IzhikevichIFSettings) && activationType != typeof(AutoIzhikevichIFSettings) ) { throw new ArgumentException($"Not allowed activation type {activationType.Name}.", "ActivationCfg"); } return; }
/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("name", Name), new XAttribute("relShare", RelShare.ToString(CultureInfo.InvariantCulture)), ActivationCfg.GetXml(suppressDefaults) ); if (!suppressDefaults || !IsDefaultHomogenousExcitabilityCfg) { rootElem.Add(HomogenousExcitabilityCfg.GetXml(suppressDefaults)); } if (BiasCfg != null) { rootElem.Add(BiasCfg.GetXml("bias", suppressDefaults)); } rootElem.Add(PredictorsCfg.GetXml(suppressDefaults)); Validate(rootElem, XsdTypeName); return(rootElem); }
/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { return(Validate(new XElement(rootElemName, new XAttribute("neurons", NumOfNeurons.ToString(CultureInfo.InvariantCulture)), ActivationCfg.GetXml(suppressDefaults)), XsdTypeName)); }