Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Issue #23 - PredictorsProvider redesign and enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
okozelsk committed Nov 25, 2020
1 parent 37cbf73 commit 46bb3a2
Show file tree
Hide file tree
Showing 50 changed files with 2,874 additions and 1,819 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public void Run()
0, //Max internal delay
0, //Max absolute value of bias
0, //Max retainment strength
new PredictorsParamsSettings(new FiringFadingSumSettings(0.05)),
PredictorsProvider.PredictorID.FiringFadingSum
new PredictorsProviderSettings(new PredictorFiringTraceSettings(0.05, 45))
);
//Display StateMachine xml configuration
string xmlConfig = stateMachineCfg.GetXml(true).ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public void Run(InputEncoder.SpikingInputEncodingRegime spikesEncodingRegime)
0.1d, //Interconnection density
0, //Internal synapses max delay
0, //Steady bias
new PredictorsParamsSettings(new FiringFadingSumSettings(0.0005)),
PredictorsProvider.PredictorID.FiringFadingSum
new PredictorsProviderSettings(new PredictorFiringTraceSettings(0.0005, 0))
);

//Display StateMachine xml configuration
Expand Down
15 changes: 8 additions & 7 deletions Demo/DemoConsoleApp/Examples/TTOOForecastDesigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ public void Run()
StateMachineDesigner smd = new StateMachineDesigner(inputCfg, readoutCfg);
//Create pure ESN fashioned StateMachine configuration
StateMachineSettings stateMachineCfg = smd.CreatePureESNCfg(250,
StateMachineDesigner.DefaultAnalogMaxInputStrength,
2.5,
1d,
0,
0.2d,
0,
0.1d,
0.75d,
null,
PredictorsProvider.PredictorID.Activation,
PredictorsProvider.PredictorID.ActivationSquare
0,
0d,
0d,
new PredictorsProviderSettings(new PredictorActivationSettings(),
new PredictorActivationPowerSettings(2d, true),
new PredictorFiringTraceSettings(0.05, 30)
)
);
//Display StateMachine xml configuration
string xmlConfig = stateMachineCfg.GetXml(true).ToString();
Expand Down
29 changes: 11 additions & 18 deletions Demo/DemoConsoleApp/Examples/TTOOForecastFromScratch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,23 @@ private AnalogNeuronGroupSettings CreateTanHGroup(string groupName, double relSh
//selected from the range 0 to 0.75 using uniform distribution
URandomValueSettings retainmentStrengthCfg = new URandomValueSettings(0, 0.75);
RetainmentSettings retainmentCfg = new RetainmentSettings(RetainmentDensity, retainmentStrengthCfg);
//Predictors configuration
//We will use Activation and ActivationSquare predictors
PredictorsProviderSettings predictorsCfg = new PredictorsProviderSettings(new PredictorActivationSettings(),
new PredictorActivationPowerSettings()
);



//Create neuron group configuration
AnalogNeuronGroupSettings groupCfg = new AnalogNeuronGroupSettings(groupName,
relShare,
new TanHSettings(),
predictorsCfg,
AnalogNeuronGroupSettings.DefaultFiringThreshold,
AnalogNeuronGroupSettings.DefaultThresholdMaxRefDeepness,
biasCfg,
retainmentCfg,
null
retainmentCfg
);
return groupCfg;
}
Expand Down Expand Up @@ -194,26 +202,11 @@ int internalMaxDelay
SynapseATIndifferentSettings synapseATIndifferentSettings = new SynapseATIndifferentSettings(Synapse.SynapticDelayMethod.Random, internalMaxDelay);
SynapseATSettings synapseATCfg = new SynapseATSettings(SynapseATSettings.DefaultSpectralRadiusNum, synapseATInputSettings, synapseATIndifferentSettings);
SynapseSettings synapseCfg = new SynapseSettings(null, synapseATCfg);
//Predictors configuration
//We use constructor accepting array of boolean switches
//Initially we set all switches to false - all available predictors are forbidden
bool[] predictorSwitches = new bool[PredictorsProvider.NumOfSupportedPredictors];
predictorSwitches.Populate(false);
//Now we enable Activation and ActivationMWAvg predictors
predictorSwitches[(int)PredictorsProvider.PredictorID.Activation] = true;
predictorSwitches[(int)PredictorsProvider.PredictorID.ActivationMWAvg] = true;
//We configure activation moving average predictor to use constant weights and last 7 values without the leaks
ActivationMWAvgSettings activationMWAvgCfg = new ActivationMWAvgSettings(7, PredictorsProvider.PredictorMWAvgWeightsType.Constant);
//We create predictors parameters configuration including custom configuration of activation moving average predictor
PredictorsParamsSettings predictorsParamsCfg = new PredictorsParamsSettings(activationMWAvgCfg);
//Create predictors configuration using prepared boolean switches and predictors parameters
PredictorsSettings predictorsCfg = new PredictorsSettings(predictorSwitches, predictorsParamsCfg);
//Create reservoir instance configuration
ReservoirInstanceSettings resInstCfg = new ReservoirInstanceSettings(instName,
structName,
new InputConnsSettings(inpConnHighCfg, inpConnLowCfg, inpConnAdjCloseP1Cfg, inpConnAdjCloseP2Cfg),
synapseCfg,
predictorsCfg
synapseCfg
);
return resInstCfg;
}
Expand Down
3 changes: 2 additions & 1 deletion Demo/DemoConsoleApp/Playground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.IO;
using System.Text;
using System.Linq;
using RCNet.MathTools;

namespace Demo.DemoConsoleApp
{
Expand Down Expand Up @@ -116,7 +117,7 @@ private void TestTransformers()
transformer = new YeoJohnsonTransformer(singleFieldList, new YeoJohnsonTransformerSettings(singleFieldList[0], 0.5d));
TestSingleFieldTransformer(transformer);
//MWStat transformer
transformer = new MWStatTransformer(singleFieldList, new MWStatTransformerSettings(singleFieldList[0], 5, MWStatTransformer.OutputValue.RootMeanSquare));
transformer = new MWStatTransformer(singleFieldList, new MWStatTransformerSettings(singleFieldList[0], 5, BasicStat.OutputFeature.RootMeanSquare));
TestSingleFieldTransformer(transformer);
//Mul transformer
transformer = new MulTransformer(twoFieldsList, new MulTransformerSettings(twoFieldsList[0], twoFieldsList[1]));
Expand Down
Loading

0 comments on commit 46bb3a2

Please sign in to comment.