diff --git a/Demo/DemoConsoleApp/SM/SMDemoSettings.xml b/Demo/DemoConsoleApp/SM/SMDemoSettings.xml index 9419b04..889a176 100644 --- a/Demo/DemoConsoleApp/SM/SMDemoSettings.xml +++ b/Demo/DemoConsoleApp/SM/SMDemoSettings.xml @@ -1,6 +1,7 @@ + - + - + - - + + - + - + - - - - - - - + + - + @@ -307,22 +307,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + @@ -345,7 +371,7 @@ - + diff --git a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/ChainSchemaSettings.cs b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/ChainSchemaSettings.cs index 9593d75..088f089 100644 --- a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/ChainSchemaSettings.cs +++ b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/ChainSchemaSettings.cs @@ -146,9 +146,9 @@ public override bool ContainsOnlyDefaults /// protected override void Check() { - if (Ratio < 0 || Ratio > 1) + if (Ratio <= 0 || Ratio > 1) { - throw new ArgumentException($"Invalid Ratio {Ratio.ToString(CultureInfo.InvariantCulture)}. Ratio must be GE to 0 and LE to 1.", "Ratio"); + throw new ArgumentException($"Invalid Ratio {Ratio.ToString(CultureInfo.InvariantCulture)}. Ratio must be GT 0 and LE to 1.", "Ratio"); } if (Repetitions < 1) { diff --git a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/EmptySchemaSettings.cs b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/EmptySchemaSettings.cs new file mode 100644 index 0000000..7fe4c38 --- /dev/null +++ b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/EmptySchemaSettings.cs @@ -0,0 +1,115 @@ +using System; +using System.Globalization; +using System.Xml.Linq; + +namespace RCNet.Neural.Network.SM.Preprocessing.Reservoir.Pool +{ + /// + /// Class contains configuration of the Empty schema of pool's neurons interconnection (ensures no internal pool connections) + /// + [Serializable] + public class EmptySchemaSettings : RCNetBaseSettings, IInterconnSchemaSettings + { + //Constants + /// + /// Name of the associated xsd type + /// + public const string XsdTypeName = "PoolInterconnectionEmptySchemaType"; + + //Constructors + /// + /// Creates an initialized instance + /// + public EmptySchemaSettings() + { + Check(); + return; + } + + /// + /// The deep copy constructor + /// + /// Source instance + public EmptySchemaSettings(EmptySchemaSettings source) + : this() + { + return; + } + + /// + /// Creates an initialized instance. + /// + /// Xml element containing the initialization settings + public EmptySchemaSettings(XElement elem) + { + //Validation + XElement settingsElem = Validate(elem, XsdTypeName); + Check(); + return; + } + + //Properties + /// + /// Specifies whether the connections of this schema will replace existing connections + /// + public bool ReplaceExistingConnections { get { return false; } } + + /// + /// Number of applications of this schema + /// + public int Repetitions { get { return 1; } } + + /// + /// Identifies settings containing only default values + /// + public override bool ContainsOnlyDefaults + { + get + { + return true; + } + } + + //Methods + /// + /// Checks consistency + /// + protected override void Check() + { + return; + } + + /// + /// Creates the deep copy instance of this instance + /// + public override RCNetBaseSettings DeepClone() + { + return new EmptySchemaSettings(this); + } + + /// + /// Generates xml element containing the settings. + /// + /// Name to be used as a name of the root element. + /// Specifies whether to ommit optional nodes having set default values + /// XElement containing the settings + public override XElement GetXml(string rootElemName, bool suppressDefaults) + { + XElement rootElem = new XElement(rootElemName); + Validate(rootElem, XsdTypeName); + return rootElem; + } + + /// + /// Generates default named xml element containing the settings. + /// + /// Specifies whether to ommit optional nodes having set default values + /// XElement containing the settings + public override XElement GetXml(bool suppressDefaults) + { + return GetXml("emptySchema", suppressDefaults); + } + + }//EmptySchemaSettings + +}//Namespace diff --git a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/InterconnSettings.cs b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/InterconnSettings.cs index abb1841..f96507a 100644 --- a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/InterconnSettings.cs +++ b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/InterconnSettings.cs @@ -87,6 +87,10 @@ public InterconnSettings(XElement elem) { SchemaCfgCollection.Add(new ChainSchemaSettings(schemaElem)); } + else if (schemaElem.Name.LocalName == "emptySchema") + { + SchemaCfgCollection.Add(new EmptySchemaSettings(schemaElem)); + } else { //Ignore @@ -111,7 +115,14 @@ protected override void Check() { if (SchemaCfgCollection.Count == 0) { - throw new ArgumentException($"At least one interconnection schema must be specified.", "SchemaCfgCollection"); + throw new InvalidOperationException($"At least one interconnection schema must be specified."); + } + foreach(IInterconnSchemaSettings schema in SchemaCfgCollection) + { + if(schema.GetType() == typeof(EmptySchemaSettings) && SchemaCfgCollection.Count > 1) + { + throw new InvalidOperationException($"No other schema specification is allowed together with EmptySchema."); + } } return; } diff --git a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/RandomSchemaSettings.cs b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/RandomSchemaSettings.cs index 1237d81..3fbab95 100644 --- a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/RandomSchemaSettings.cs +++ b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/Pool/RandomSchemaSettings.cs @@ -192,9 +192,9 @@ public override bool ContainsOnlyDefaults /// protected override void Check() { - if (Density < 0 || Density > 1) + if (Density <= 0 || Density > 1) { - throw new ArgumentException($"Invalid Density {Density.ToString(CultureInfo.InvariantCulture)}. Density must be GE to 0 and LE to 1.", "Density"); + throw new ArgumentException($"Invalid Density {Density.ToString(CultureInfo.InvariantCulture)}. Density must be GT 0 and LE to 1.", "Density"); } if (AvgDistance < 0) { diff --git a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/ReservoirInstance.cs b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/ReservoirInstance.cs index e567ca9..a098809 100644 --- a/RCNet/Neural/Network/SM/Preprocessing/Reservoir/ReservoirInstance.cs +++ b/RCNet/Neural/Network/SM/Preprocessing/Reservoir/ReservoirInstance.cs @@ -265,7 +265,12 @@ Random rand //Apply defined schemas foreach (object connSchema in StructureCfg.PoolsCfg.PoolCfgCollection[poolID].InterconnectionCfg.SchemaCfgCollection) { - if (connSchema.GetType() == typeof(RandomSchemaSettings)) + if (connSchema.GetType() == typeof(EmptySchemaSettings)) + { + //No interconnection + break; + } + else if (connSchema.GetType() == typeof(RandomSchemaSettings)) { ConnectRandomSchema(poolID, rand, (RandomSchemaSettings)connSchema); } diff --git a/RCNet/RCNet.csproj b/RCNet/RCNet.csproj index 76016f0..a459608 100644 --- a/RCNet/RCNet.csproj +++ b/RCNet/RCNet.csproj @@ -198,6 +198,7 @@ + diff --git a/RCNet/RCNetTypes.xsd b/RCNet/RCNetTypes.xsd index aff09b3..2d68ff1 100644 --- a/RCNet/RCNetTypes.xsd +++ b/RCNet/RCNetTypes.xsd @@ -262,6 +262,14 @@ + + + + + + + + @@ -1762,9 +1770,13 @@ + + + + - + Default value is 0.1 @@ -1798,7 +1810,7 @@ - + Default value is 1 @@ -1822,12 +1834,17 @@ - - - - - - + + + + + + + + + + + diff --git a/Readme.md b/Readme.md index 4a2b87a..77302af 100644 --- a/Readme.md +++ b/Readme.md @@ -36,7 +36,7 @@ site and State Machine usually achieves very similar results to the best classif |--|--|--|--| |[CricketX](https://timeseriesclassification.com/description.php?Dataset=CricketX)|80.77%|81.4%|COTE| |[Worms](https://timeseriesclassification.com/description.php?Dataset=Worms)|83.12%|73.49%|BOSS| -|[BeetleFly](https://timeseriesclassification.com/description.php?Dataset=BeetleFly)|95%|94.85%|BOSS| +|[BeetleFly](https://timeseriesclassification.com/description.php?Dataset=BeetleFly)|100%|94.85%|BOSS| |[BirdChicken](https://timeseriesclassification.com/description.php?Dataset=BirdChicken)|100%|98.4%|BOSS| |[ProximalPhalanx](https://timeseriesclassification.com/description.php?Dataset=ProximalPhalanxOutlineAgeGroup)|88.29%|88.09%|ST| |[Yoga](https://timeseriesclassification.com/description.php?Dataset=Yoga)|91.13%|90.99%|BOSS|