//Methods /// <summary> /// Resets the predictors provider to its initial state. /// </summary> public void Reset() { _activationMDW?.Reset(); _firingMDW?.Reset(); _activationStat?.Reset(); _activationDiffStat?.Reset(); _lastActivation = 0d; _lastNormalizedActivation = 0d; _lastSpike = false; //Predictors foreach (IPredictor predictor in _predictorCollection) { predictor.Reset(); } return; }
//Methods public void Run() { //Filter test RealFeatureFilter rff = new RealFeatureFilter(new Interval(-1, 1)); for (int i = 1; i <= 1500; i++) { rff.Update(_rand.NextDouble() * _rand.Next(0, 10000)); } double featureValue = 0.5; double filterValue = rff.ApplyFilter(featureValue); double reverseValue = rff.ApplyReverse(filterValue); Console.WriteLine($"Feature: {featureValue} Filter: {filterValue} Reverse: {reverseValue}"); //Pulse generator test BasicStat sampleStat = new BasicStat(); sampleStat.Reset(); PulseGeneratorSettings modSettings = new PulseGeneratorSettings(1, 1.5, PulseGeneratorSettings.TimingMode.Poisson); IGenerator generator = new PulseGenerator(modSettings); int steps = 10000; double period = 0; for (int i = 0; i < steps; i++) { ++period; double sample = generator.Next(); //Console.WriteLine(sample); if (sample != 0) { sampleStat.AddSampleValue(period); period = 0; } } Console.WriteLine($"Mean: {sampleStat.ArithAvg} StdDev: {sampleStat.StdDev} Min: {sampleStat.Min} Max: {sampleStat.Max}"); Console.ReadLine(); //Random distributions test BasicStat rStat = new BasicStat(); for (int i = 0; i < 200; i++) { double r = _rand.NextFilterredGaussianDouble(0.5, 1, -0.5, 1); rStat.AddSampleValue(r); Console.WriteLine(r); } Console.WriteLine($"Mean: {rStat.ArithAvg} StdDev: {rStat.StdDev} Min: {rStat.Min} Max: {rStat.Max}"); Console.ReadLine(); //Activation tests double fadingSum = 0; for (int i = 0; i < 1000; i++) { fadingSum *= (1d - 0.1); fadingSum += 1d; Console.WriteLine(fadingSum); } Console.ReadLine(); IActivationFunction testAF = ActivationFactory.Create(new SimpleIFSettings(refractoryPeriods: 0), new Random(0)); TestActivation(testAF, 100, 3.5, 10, 70); SimpleIFSettings setup = new SimpleIFSettings(); FindAFInputBorders(ActivationFactory.Create(setup, new Random(0)), -0.1, 20 ); //Linear algebra test double[] flatData = { 0.2, 5, 17.3, 1.01, 54, 7, 2.2, 5.5, 12.13, 11.57, 5.71, -85, -70.1, 15, -18.3, 0.3, 42, -6.25, 0.042, 1, 7.75, -81.01, -21.29, 5.44, 0.1, 4, -4.3, 18.01, 7.12, -3.14, -80.1, 24.4, 4.3, 12.03, 2.789, -13 }; Matrix testM = new Matrix(6, 6, flatData); /* * //Inversion test * Matrix resultM = new Matrix(testM); * resultM.SingleThreadInverse(); */ /* * //Transpose test * Matrix resultM = testM.Transpose(); */ /* * //Multiply test * Matrix resultM = Matrix.Multiply(testM, testM); * for (int i = 0; i < resultM.NumOfRows; i++) * { * Console.WriteLine($"{resultM.Data[i][0]}; {resultM.Data[i][1]}; {resultM.Data[i][2]}; {resultM.Data[i][3]}; {resultM.Data[i][4]}; {resultM.Data[i][5]}"); * } */ ; int numOfweights = 3; int xIdx, dIdx = 0; double[][] data = new double[3][]; data[dIdx] = new double[numOfweights]; xIdx = -1; data[dIdx][++xIdx] = 2; data[dIdx][++xIdx] = 1; data[dIdx][++xIdx] = 3; ++dIdx; data[dIdx] = new double[numOfweights]; xIdx = -1; data[dIdx][++xIdx] = 1; data[dIdx][++xIdx] = 3; data[dIdx][++xIdx] = -3; ++dIdx; data[dIdx] = new double[numOfweights]; xIdx = -1; data[dIdx][++xIdx] = -2; data[dIdx][++xIdx] = 4; data[dIdx][++xIdx] = 4; //Matrix M = new Matrix(data, true); //Matrix I = M.Inverse(false); //Matrix identity = M * I; //Must lead to identity matrix Matrix I = new Matrix(3, 3); I.AddScalarToDiagonal(1); Matrix X = new Matrix(I); X.Multiply(0.1); Matrix XT = X.Transpose(); Matrix R = XT * X; Console.ReadLine(); ///* SimpleIFSettings settings = new SimpleIFSettings(new RandomValueSettings(15, 15), new RandomValueSettings(0.05, 0.05), new RandomValueSettings(5, 5), new RandomValueSettings(20, 20), 0 ); IActivationFunction af = ActivationFactory.Create(settings, new Random(0)); //*/ TestActivation(af, 800, 0.15, 10, 600); return; }