//Constructor /// <summary> /// Creates an initialized instance /// </summary> /// <param name="inputFieldIdx">Index of corresponding reservoir input field.</param> /// <param name="inputRange"> /// Range of input value. /// It is very recommended to have input values normalized and standardized before /// they are passed to input neuron. /// </param> /// <param name="inputCodingFractions">Number of coding fractions (see SpikeTrainConverter to understand)</param> public InputSpikingNeuron(int inputFieldIdx, Interval inputRange, int inputCodingFractions) { Placement = new NeuronPlacement(inputFieldIdx, -1, inputFieldIdx, inputFieldIdx, 0, 0); _inputRange = new Interval(inputRange.Min.Bound(), inputRange.Max.Bound()); _signalConverter = new SignalConverter(_inputRange, inputCodingFractions); StimuliStat = new BasicStat(); TransmissionSignalStat = new BasicStat(); Reset(false); return; }
/// <summary> /// Function mixes three analog values in the specified range into the one. /// Order of values: the first is the most important. /// </summary> /// <param name="analogRange">Range of analog values</param> /// <param name="a1">Analog value 1</param> /// <param name="a2">Analog value 2</param> /// <param name="a3">Analog value 3</param> /// <param name="s1">Spikes (bits) for analog value 1</param> /// <param name="s2">Spikes (bits) for analog value 2</param> /// <param name="s3">Spikes (bits) for analog value 3</param> /// <returns></returns> public static double Mix(Interval analogRange, double a1, double a2, double a3, int s1, int s2, int s3 ) { //Check spikes if (s1 + s2 + s3 > MaxCodingFractions) { throw new Exception("s1 + s2 +s3 > MaxCodingSpikes"); } SignalConverter sc1 = new SignalConverter(analogRange, s1); SignalConverter sc2 = new SignalConverter(analogRange, s2); SignalConverter sc3 = new SignalConverter(analogRange, s3); SignalConverter scm = new SignalConverter(analogRange, s1 + s2 + s3); sc1.EncodeAnalogValue(a1); sc2.EncodeAnalogValue(a2); sc3.EncodeAnalogValue(a3); ulong buffer = 0; for (int i = 0; i < s1; i++) { buffer <<= 1; ulong bit = (ulong)sc1.FetchSpike(); buffer |= bit; } for (int i = 0; i < s2; i++) { buffer <<= 1; ulong bit = (ulong)sc2.FetchSpike(); buffer |= bit; } for (int i = 0; i < s3; i++) { buffer <<= 1; ulong bit = (ulong)sc3.FetchSpike(); buffer |= bit; } scm.EncodeSpikeTrain(buffer); return(scm.FetchAnalogValue()); }