1 namespace SpikingNeuronNetwork.Test
4 using Lib.NeuronModels;
5 using Microsoft.VisualStudio.TestTools.UnitTesting;
7 using System.Collections.Generic;
16 public static List<Spike> InputSpikeTimes =
new List<Spike>
18 new Spike { Time = 2, NeuronIndex = 0},
19 new Spike { Time = 1, NeuronIndex = 1},
20 new Spike { Time = 1.5, NeuronIndex = 2},
21 new Spike { Time = 4, NeuronIndex = 3},
32 const int numInputs = 4;
34 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
45 const int numInputs = 4;
46 var thetaNeuron =
new ThetaNeuron(numInputs, 0.2, 0.01);
47 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
54 const int numInputs = 4;
55 var thetaNeuron =
new ThetaNeuron(numInputs, -0.001, 0.01);
56 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
63 const int numInputs = 4;
64 var thetaNeuron =
new ThetaNeuron(numInputs, 1e6, 0.01);
65 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
72 const int numInputs = 4;
74 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
81 const int numInputs = 4;
82 var thetaNeuron =
new ThetaNeuron(numInputs, -0.01);
83 TestHelper.CompareNumericalAndEventDrivenSpikeTrains(thetaNeuron, InputSpikeTimes);
89 for (var j2 = 0; j2 < 1000; j2++)
91 const int numInputs = 4;
92 const int maxNumOutputSpikes = 3;
98 Console.WriteLine(thetaNeuron);
101 thetaNeuron.Method = SimulationMethod.EventDriven;
102 var outputSpikeTimesEventDriven =
103 thetaNeuron.RunThetaNeuron(InputSpikeTimes, maxNumOutputSpikes).ToList();
106 if (outputSpikeTimesEventDriven.Count <= 0)
return;
107 Console.WriteLine(
"A second neuron is simulated in connection to the output of the previous neuron");
109 var outputSpikeTimesList =
110 outputSpikeTimesEventDriven.Select((t, j) =>
new Spike {Time = t.Time, NeuronIndex = j}).ToList();
111 var outputSpikeTimesEventDriven2 =
112 thetaNeuron2.RunThetaNeuron(outputSpikeTimesList, maxNumOutputSpikes).ToList();
113 if (outputSpikeTimesEventDriven2.Count > 0)
115 Assert.IsTrue(outputSpikeTimesEventDriven.First().Time < outputSpikeTimesEventDriven2.First().Time);
Tests theta neuron functionality
void ThetaNeuronIdenticalNegativeWeightsMethodTest()
void ThetaNeuronIdenticalPositiveIoNegativeWeightsMethodTest()
void ThetaNeuronIdenticalPositiveIoRandomizedWeightsMethodTest()
void ThetaNeuronRandomWeightsMethodTest()
Tests numerical and event-driven results are equivalent for a theta neuron with 4 inputs and random w...
void ThetaNeuronStackedTest()
void ThetaNeuronIdenticalPositiveWeightsMethodTest()
void ThetaNeuronIdenticalPositiveIoPositiveWeightsMethodTest()
Tests numerical and event-driven results are equivalent for a theta neuron with 4 inputs and random w...