/// <summary> /// Resets all associated input neurons to initial state /// </summary> /// <param name="statistics">Specifies whether to reset internal statistics of the associated neurons</param> public void ResetNeurons(bool statistics) { _realSpikeCode?.Reset(); AnalogNeuron.Reset(statistics); for (int i = 0; i < SpikingNeuronCollection.Length; i++) { SpikingNeuronCollection[i].Reset(statistics); } return; }
/// <summary> /// Fetches the next piece of current data. /// </summary> /// <param name="collectStatistics">Specifies whether to update internal statistics of input neurons.</param> public bool Fetch(bool collectStatistics) { if (_currentDataIdx == 0 || (_spikesEncoder.Regime == InputEncoder.InputSpikesCoding.Vertical && _currentDataIdx < _spikesEncoder.LargestComponentLength)) { switch (_spikesEncoder.Regime) { case InputEncoder.InputSpikesCoding.Horizontal: { //Analog neuron AnalogNeuron.NewStimulation(_iAnalogStimuli, 0d); AnalogNeuron.Recompute(collectStatistics); //Spiking neurons for (int i = 0; i < SpikingNeuronCollection.Length; i++) { SpikingNeuronCollection[i].NewStimulation(_spikesEncoder.AllSpikesFlatCollection[i], 0d); SpikingNeuronCollection[i].Recompute(collectStatistics); } } break; case InputEncoder.InputSpikesCoding.Vertical: { //Analog neuron AnalogNeuron.NewStimulation(_iAnalogStimuli, 0d); AnalogNeuron.Recompute(collectStatistics); //Spiking neurons for (int i = 0; i < _spikesEncoder.ComponentSpikesCollection.Length; i++) { SpikingNeuronCollection[i].NewStimulation(_spikesEncoder.ComponentSpikesCollection[i][_currentDataIdx], 0d); SpikingNeuronCollection[i].Recompute(collectStatistics); } } break; default: //Only analog neuron AnalogNeuron.NewStimulation(_iAnalogStimuli, 0d); AnalogNeuron.Recompute(collectStatistics); break; } ++_currentDataIdx; return(true); } return(false); }
/// <summary> /// Prepares input neurons to provide new incoming data. /// </summary> /// <param name="value">External natural input data</param> /// <param name="collectStatistics">Specifies whether to update internal statistics of associated input neurons</param> public void SetNewData(double value, bool collectStatistics) { double iStimuli = _featureFilter.ApplyFilter(value); //Analog neuron AnalogNeuron.NewStimulation(iStimuli, 0d); AnalogNeuron.Recompute(collectStatistics); //Spiking neurons switch (_featureFilter.Type) { case FeatureFilterBase.FeatureType.Real: { _realSpikeCode.Encode(iStimuli); for (int i = 0; i < SpikingNeuronCollection.Length; i++) { SpikingNeuronCollection[i].NewStimulation(_realSpikeCode.Code[i], 0d); SpikingNeuronCollection[i].Recompute(collectStatistics); } } break; case FeatureFilterBase.FeatureType.Binary: { SpikingNeuronCollection[0].NewStimulation(value, 0d); SpikingNeuronCollection[0].Recompute(collectStatistics); } break; case FeatureFilterBase.FeatureType.Enum: { int neuronIdx = ((int)Math.Round(value, 0)) - 1; for (int i = 0; i < SpikingNeuronCollection.Length; i++) { double spikeVal = i == neuronIdx ? 1d : 0d; SpikingNeuronCollection[i].NewStimulation(spikeVal, 0d); SpikingNeuronCollection[i].Recompute(collectStatistics); } } break; } return; }