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

Commit 588bb84

Browse files
committed
Cleanup and doc. images
1 parent 1387386 commit 588bb84

17 files changed

+225
-77
lines changed

Demo/DemoConsoleApp/Examples/TTOOForecastFromScratch.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
using System;
2-
using System.IO;
3-
using RCNet.Extensions;
4-
using RCNet.Neural.Activation;
5-
using RCNet.Neural.Data.Coders.AnalogToSpiking;
1+
using RCNet.Neural.Activation;
62
using RCNet.Neural.Data.Filter;
73
using RCNet.Neural.Network.NonRecurrent;
84
using RCNet.Neural.Network.NonRecurrent.FF;
95
using RCNet.Neural.Network.SM;
106
using RCNet.Neural.Network.SM.Preprocessing;
117
using RCNet.Neural.Network.SM.Preprocessing.Input;
12-
using RCNet.Neural.Network.SM.Preprocessing.Neuron;
138
using RCNet.Neural.Network.SM.Preprocessing.Neuron.Predictor;
149
using RCNet.Neural.Network.SM.Preprocessing.Reservoir;
1510
using RCNet.Neural.Network.SM.Preprocessing.Reservoir.Pool;
@@ -18,6 +13,8 @@
1813
using RCNet.Neural.Network.SM.Preprocessing.Reservoir.SynapseNS;
1914
using RCNet.Neural.Network.SM.Readout;
2015
using RCNet.RandomValue;
16+
using System;
17+
using System.IO;
2118

2219
namespace Demo.DemoConsoleApp.Examples
2320
{
@@ -116,7 +113,7 @@ private PoolSettings CreateAnalogPoolCfg(string poolName, int dimX, int dimY, in
116113
PoolSettings poolCfg = new PoolSettings(poolName,
117114
new ProportionsSettings(dimX, dimY, dimZ),
118115
new NeuronGroupsSettings(grpCfg),
119-
new InterconnSettings(chainSchemaCfg, randomSchemaCfg )
116+
new InterconnSettings(chainSchemaCfg, randomSchemaCfg)
120117
);
121118
return poolCfg;
122119
}
@@ -332,7 +329,7 @@ public void Run()
332329
stateMachine.Serialize(serializationFileName);
333330

334331
//Forecasting
335-
double[] outputVector = stateMachine.Compute(predictionInputVector, out ReadoutLayer.ReadoutData readoutData);
332+
double[] outputVector = stateMachine.Compute(predictionInputVector, out ReadoutLayer.ReadoutData readoutData);
336333
_log.Write(" Forecasted next High and Low TTOO prices (real prices on 2018/03/05 are High=6.58$ and Low=5.99$):", false);
337334
_log.Write(stateMachine.RL.GetForecastReport(outputVector, 6));
338335
_log.Write(string.Empty);

Demo/DemoConsoleApp/Playground.cs

+32-29
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,13 @@ private void TestProbabilisticClusterAndBuilder(string trainDataFile, string ver
354354
VectorBundle verifyData = VectorBundle.Load(verifyCsvData, numOfClasses);
355355
Console.WriteLine($"Cluster training on {trainDataFile}...");
356356
//TRAINING
357-
List<FeedForwardNetworkSettings> netCfgs = new List<FeedForwardNetworkSettings>();
358-
netCfgs.Add(new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
359-
new HiddenLayersSettings(new HiddenLayerSettings(30, new AFAnalogTanHSettings())),
360-
new RPropTrainerSettings(5, 750)
361-
)
362-
);
357+
List<FeedForwardNetworkSettings> netCfgs = new List<FeedForwardNetworkSettings>
358+
{
359+
new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
360+
new HiddenLayersSettings(new HiddenLayerSettings(30, new AFAnalogTanHSettings())),
361+
new RPropTrainerSettings(5, 750)
362+
)
363+
};
363364
ITNRNetClusterSettings clusterCfg = new TNRNetClusterProbabilisticSettings(new TNRNetClusterProbabilisticNetworksSettings(netCfgs),
364365
new TNRNetClusterProbabilisticWeightsSettings()
365366
);
@@ -415,26 +416,27 @@ private void TestProbabilisticClusterChainAndBuilder(string trainDataFile, strin
415416
//Common crossvalidation configuration
416417
CrossvalidationSettings crossvalidationCfg = new CrossvalidationSettings(foldDataRatio, 0, 2);
417418
//TRAINING
418-
List<FeedForwardNetworkSettings> netCfgs1 = new List<FeedForwardNetworkSettings>();
419-
netCfgs1.Add(new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
420-
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogTanHSettings())),
421-
new RPropTrainerSettings(5, 750)
422-
)
423-
);
424-
netCfgs1.Add(new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
425-
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogLeakyReLUSettings())),
426-
new RPropTrainerSettings(5, 750)
427-
)
428-
);
419+
List<FeedForwardNetworkSettings> netCfgs1 = new List<FeedForwardNetworkSettings>
420+
{
421+
new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
422+
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogTanHSettings())),
423+
new RPropTrainerSettings(5, 750)
424+
),
425+
new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
426+
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogLeakyReLUSettings())),
427+
new RPropTrainerSettings(5, 750)
428+
)
429+
};
429430
TNRNetClusterProbabilisticSettings clusterCfg1 = new TNRNetClusterProbabilisticSettings(new TNRNetClusterProbabilisticNetworksSettings(netCfgs1),
430431
new TNRNetClusterProbabilisticWeightsSettings()
431432
);
432-
List<FeedForwardNetworkSettings> netCfgs2 = new List<FeedForwardNetworkSettings>();
433-
netCfgs2.Add(new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
434-
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogTanHSettings())),
435-
new RPropTrainerSettings(5, 750)
436-
)
437-
);
433+
List<FeedForwardNetworkSettings> netCfgs2 = new List<FeedForwardNetworkSettings>
434+
{
435+
new FeedForwardNetworkSettings(new AFAnalogSoftMaxSettings(),
436+
new HiddenLayersSettings(new HiddenLayerSettings(20, new AFAnalogTanHSettings())),
437+
new RPropTrainerSettings(5, 750)
438+
)
439+
};
438440
TNRNetClusterProbabilisticSettings clusterCfg2 = new TNRNetClusterProbabilisticSettings(new TNRNetClusterProbabilisticNetworksSettings(netCfgs2),
439441
new TNRNetClusterProbabilisticWeightsSettings()
440442
);
@@ -489,12 +491,13 @@ private void TestRealClusterAndBuilder(string trainDataFile, string verifyDataFi
489491
VectorBundle verifyData = VectorBundle.Load(verifyCsvData, numOfClasses);
490492
Console.WriteLine($"Cluster training on {trainDataFile}...");
491493
//TRAINING
492-
List<FeedForwardNetworkSettings> netCfgs = new List<FeedForwardNetworkSettings>();
493-
netCfgs.Add(new FeedForwardNetworkSettings(new AFAnalogIdentitySettings(),
494-
new HiddenLayersSettings(new HiddenLayerSettings(30, new AFAnalogTanHSettings())),
495-
new RPropTrainerSettings(5, 750)
496-
)
497-
);
494+
List<FeedForwardNetworkSettings> netCfgs = new List<FeedForwardNetworkSettings>
495+
{
496+
new FeedForwardNetworkSettings(new AFAnalogIdentitySettings(),
497+
new HiddenLayersSettings(new HiddenLayerSettings(30, new AFAnalogTanHSettings())),
498+
new RPropTrainerSettings(5, 750)
499+
)
500+
};
498501
ITNRNetClusterSettings clusterCfg = new TNRNetClusterRealSettings(new TNRNetClusterRealNetworksSettings(netCfgs),
499502
new TNRNetClusterRealWeightsSettings()
500503
);

Demo/DemoConsoleApp/SMDemoSettings.xml

+155-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,160 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<demo dataFolder="./Data" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SMDemoSettings.xsd">
33

4+
5+
6+
7+
<case name="Classification task CricketX: Pure ESN reservoir generating FiringTrace predictors, one Identity neuron as a classifier (Resilient trainer)">
8+
<samples trainingData="CricketX_train.csv" verificationData="CricketX_verify.csv"/>
9+
<stateMachine randomizerSeek="0">
10+
<neuralPreprocessor predictorsReductionRatio="0" predictorValueMinSpan="1e-6">
11+
<inputEncoder>
12+
<feedingPatterned slices="1" bidir="Continuous" variablesSchema="Sequential">
13+
<unification detrend="false" unifyAmplitude="false">
14+
<resampling signalBeginThreshold="0" signalEndThreshold="0" uniformTimeScale="true" targetTimePoints="Auto"/>
15+
</unification>
16+
<steadyFields>
17+
<field name="xxx" routeToReadout="true"/>
18+
<field name="yyy" routeToReadout="true"/>
19+
</steadyFields>
20+
</feedingPatterned>
21+
<varyingFields routeToReadout="false">
22+
<spikesCoder regime="Horizontal">
23+
<downDirArrowsCoder timePoints="8" receptors="8"/>
24+
<upDirArrowsCoder timePoints="8" receptors="8"/>
25+
<gaussianReceptorsCoder timePoints="8" receptors="8"/>
26+
<signalStrengthCoder timePoints="8"/>
27+
</spikesCoder>
28+
<externalFields>
29+
<field name="Accel" routeToReadout="true">
30+
<realFeature standardize="true" keepReserve="true"/>
31+
</field>
32+
</externalFields>
33+
<generatedFields>
34+
<field name="rrrr" routeToReadout="true">
35+
<random min="0.2" max="0.5" randomSign="true">
36+
<gammaDistr beta="0.4" alpha="0.5"/>
37+
<exponentialDistr mean="2.4"/>
38+
<gaussianDistr mean="0" stdDev="1"/>
39+
</random>
40+
<sinusoidal freq="1.5" ampl="0.5" phase="0.47"/>
41+
<pulse mode="Uniform" avgPeriod="3.5" signal="1"/>
42+
<mackeyGlass b="0.45" c="1.25" tau="18"/>
43+
44+
<realFeature/>
45+
</field>
46+
</generatedFields>
47+
</varyingFields>
48+
</inputEncoder>
49+
<reservoirStructures>
50+
<reservoirStructure name="MainCfg">
51+
<pools>
52+
<pool name="PoolMain">
53+
<proportions dimX="500" dimY="1" dimZ="1"/>
54+
<neuronGroups>
55+
<analogGroup name="TanH-grp" relShare="1" firingThreshold="0.00125" thresholdMaxRefDeepness="60">
56+
<activationTanH/>
57+
<predictors>
58+
<firingTrace fading="0.005"/>
59+
</predictors>
60+
</analogGroup>
61+
</neuronGroups>
62+
<interconnection>
63+
<randomSchema density="0.05" avgDistance="NA" allowSelfConnection="true"/>
64+
<chainSchema/>
65+
</interconnection>
66+
</pool>
67+
</pools>
68+
</reservoirStructure>
69+
</reservoirStructures>
70+
<reservoirInstances>
71+
<reservoirInstance name="Main" reservoirStructure="MainCfg">
72+
<inputConnections>
73+
<connection inputFieldName="Accel" poolName="PoolMain" analogTargetDensity="0.25"/>
74+
</inputConnections>
75+
<synapse>
76+
<analogTarget spectralRadius="0.9999">
77+
<input maxDelay="50">
78+
<analogSource>
79+
<weight min="0" max="1.5"/>
80+
</analogSource>
81+
</input>
82+
<indifferent maxDelay="0"/>
83+
</analogTarget>
84+
</synapse>
85+
</reservoirInstance>
86+
</reservoirInstances>
87+
</neuralPreprocessor>
88+
<readoutLayer>
89+
<taskDefaults>
90+
<classification>
91+
<clusterChain>
92+
<crossvalidation foldDataRatio="0.1" folds="Auto" repetitions="1"/>
93+
<clusters>
94+
<cluster>
95+
<networks>
96+
<ff>
97+
<activationIdentity/>
98+
<resPropTrainer attempts="10" attemptEpochs="500"/>
99+
</ff>
100+
</networks>
101+
<weights/>
102+
</cluster>
103+
</clusters>
104+
</clusterChain>
105+
</classification>
106+
</taskDefaults>
107+
<readoutUnits>
108+
<readoutUnit name="Cancel Call">
109+
<classification oneTakesAllGroupName="Gesture"/>
110+
</readoutUnit>
111+
<readoutUnit name="Dead Ball">
112+
<classification oneTakesAllGroupName="Gesture"/>
113+
</readoutUnit>
114+
<readoutUnit name="Four">
115+
<classification oneTakesAllGroupName="Gesture"/>
116+
</readoutUnit>
117+
<readoutUnit name="Last Hour">
118+
<classification oneTakesAllGroupName="Gesture"/>
119+
</readoutUnit>
120+
<readoutUnit name="Leg Bye">
121+
<classification oneTakesAllGroupName="Gesture"/>
122+
</readoutUnit>
123+
<readoutUnit name="No Ball">
124+
<classification oneTakesAllGroupName="Gesture"/>
125+
</readoutUnit>
126+
<readoutUnit name="One Short">
127+
<classification oneTakesAllGroupName="Gesture"/>
128+
</readoutUnit>
129+
<readoutUnit name="Out">
130+
<classification oneTakesAllGroupName="Gesture"/>
131+
</readoutUnit>
132+
<readoutUnit name="Penalty Runs">
133+
<classification oneTakesAllGroupName="Gesture"/>
134+
</readoutUnit>
135+
<readoutUnit name="Six">
136+
<classification oneTakesAllGroupName="Gesture"/>
137+
</readoutUnit>
138+
<readoutUnit name="TV Replay">
139+
<classification oneTakesAllGroupName="Gesture"/>
140+
</readoutUnit>
141+
<readoutUnit name="Wide">
142+
<classification oneTakesAllGroupName="Gesture"/>
143+
</readoutUnit>
144+
</readoutUnits>
145+
<oneTakesAllGroups>
146+
<group name="Gesture">
147+
<basicDecision/>
148+
</group>
149+
</oneTakesAllGroups>
150+
</readoutLayer>
151+
</stateMachine>
152+
</case>
153+
154+
155+
156+
157+
4158
<!--
5159
Here StateMachine achieves 82.05% accuracy. It is a bit better than the best accuracy 81.4% achieved by the algorithm
6160
called COTE referenced at the dataset's home site:
@@ -19,7 +173,7 @@
19173
<stateMachine randomizerSeek="0">
20174
<neuralPreprocessor predictorsReductionRatio="0">
21175
<inputEncoder>
22-
<feedingPatterned slices="1" bidir="Continuous" variablesSchema="Sequential"/>
176+
<feedingPatterned slices="1" bidir="Continuous" variablesSchema="Sequential" />
23177
<varyingFields routeToReadout="false">
24178
<spikesCoder regime="Forbidden"/>
25179
<externalFields>

Demo/DemoConsoleApp/TimeSeriesGenerator.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,11 @@ public static List<double> GenMackeyGlassTimeSeries(int length, int tau = 18, do
7878
/// <param name="cultureInfo">The culture info object to be used.</param>
7979
public static void SaveTimeSeriesToCsvFile(string fileName, string valueColumnName, List<double> dataCollection, CultureInfo cultureInfo)
8080
{
81-
using (StreamWriter streamWriter = new StreamWriter(new FileStream(fileName, FileMode.Create)))
81+
using StreamWriter streamWriter = new StreamWriter(new FileStream(fileName, FileMode.Create));
82+
streamWriter.WriteLine(valueColumnName);
83+
foreach (double value in dataCollection)
8284
{
83-
streamWriter.WriteLine(valueColumnName);
84-
foreach (double value in dataCollection)
85-
{
86-
streamWriter.WriteLine(value.ToString("F20", cultureInfo));
87-
}
85+
streamWriter.WriteLine(value.ToString("F20", cultureInfo));
8886
}
8987
return;
9088
}
Loading
Loading
Binary file not shown.
-3.03 KB
Loading
-52.7 KB
Binary file not shown.
Loading
Loading

RCNet/Docs/Imgs/TanH.png

-16.4 KB
Loading

RCNet/Neural/Network/SM/Preprocessing/Input/InputEncoder.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ public InputEncoder(InputEncoderSettings inputEncoderCfg)
196196
foreach (ExternalFieldSettings fieldCfg in _encoderCfg.VaryingFieldsCfg.ExternalFieldsCfg.FieldCfgCollection)
197197
{
198198
_varyingFields.Add(new InputField(fieldCfg.Name,
199-
fieldIdx++,
200-
coordinates,
201-
Interval.IntN1P1,
202-
fieldCfg.FeatureFilterCfg,
203-
_encoderCfg.VaryingFieldsCfg.InputSpikesCoderCfg,
204-
(fieldCfg.RouteToReadout && _encoderCfg.VaryingFieldsCfg.RouteToReadout),
205-
inputNeuronStartIdx
206-
));
199+
fieldIdx++,
200+
coordinates,
201+
Interval.IntN1P1,
202+
fieldCfg.FeatureFilterCfg,
203+
_encoderCfg.VaryingFieldsCfg.InputSpikesCoderCfg,
204+
(fieldCfg.RouteToReadout && _encoderCfg.VaryingFieldsCfg.RouteToReadout),
205+
inputNeuronStartIdx
206+
));
207207
inputNeuronStartIdx += _varyingFields[(fieldIdx - _numOfSteadyFields) - 1].NumOfInputNeurons;
208208
}
209209
//Internal input transformers and fields

RCNet/Neural/Network/SM/Preprocessing/NeuralPreprocessor.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ public enum BidirProcessing
4545
/// <param name="totalNumOfInputs">The total number of inputs to be processed.</param>
4646
/// <param name="numOfProcessedInputs">The number of already processed inputs.</param>
4747
/// <param name="finalPreprocessingOverview">The final overview of the preprocessing.</param>
48-
public delegate void PreprocessingProgressChangedDelegate(int totalNumOfInputs,
49-
int numOfProcessedInputs,
50-
PreprocessingOverview finalPreprocessingOverview
51-
);
48+
public delegate void PreprocessingProgressChangedHandler(int totalNumOfInputs,
49+
int numOfProcessedInputs,
50+
PreprocessingOverview finalPreprocessingOverview
51+
);
5252
//Events
5353
/// <summary>
5454
/// This informative event occurs every time the progress of neural preprocessing has changed.
5555
/// </summary>
5656
[field: NonSerialized]
57-
public event PreprocessingProgressChangedDelegate PreprocessingProgressChanged;
57+
public event PreprocessingProgressChangedHandler PreprocessingProgressChanged;
5858

5959

6060
//Attribute properties

0 commit comments

Comments
 (0)