Encoders

Spike encoders for Spiking Neural Network (spatio-temporal data)

There are two types of encoders:

Bens Spiker Algorithm

class spikes.encoder.BSA(data, threshold=0.5, filter_length=2, cutoff=0.8)[source]

Bens Spiker Algorithm (BSA) uses Finite Impulse Response (FIR) filter to try a reverse convolution of the stimulation (converting spikes to analog values). A principle borrowed from unpublished modified Hough Spiker Algorithm (HSA) 2.

2

Schrauwen, B., & Van Campenhout, J. (2003, July). BSA, a fast and accurate spike train encoding scheme. In Proceedings of the international joint conference on neural networks (Vol. 4, No. 4, pp. 2825-2830). Piscataway, NJ: IEEE.

Parameters
  • data (ndarray) – See :py:mod: nucube.utils.ReadCSV.get_samples()

  • threshold (float) – Threshold level for spike. It can also be a list of threshold according to the numbers of input features.

  • filter_length (int) –

  • cutoff (float) –

_fir_filter()[source]

This method returns FIR filter using window method.

Return type

dict

Return flow

The dictionary contains the following:

  • filter_values: A list of float.

  • filter_length: The length of filter_value

get_spike_time(offset=100)[source]

Merges the samples and returns the time at which the spike happens. Spike time always startes with 1 and increases with :param: offset.

Parameters

offset (int) – Shifting the spike index to the given number, if the first index is 0, then it will always be 1

Return type

list

Returns

Spike time with an offset.

get_spikes()[source]

Returns BSA spikes.

Return type

ndarray

Return output

Returns an multidimensional ndarray where each ndarray of ndarray is a sample.

See ReadData on how to setup the files.

>>> spike_object = BSA()
>>> spike_object.get_spikes()
[[[1 1 1 ... 0 0 0]
  [1 1 1 ... 1 1 1]
  [1 1 1 ... 0 1 1]
  ...
  [1 1 1 ... 1 1 1]
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]]
 [[0 1 1 ... 1 1 1]
  [1 1 1 ... 1 1 1]
  [0 1 0 ... 1 0 1]
  ...
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]
  [0 0 0 ... 0 0 0]]]

Threshold Based Representation

class spikes.encoder.TBR(data, threshold=0.5)[source]

Threshold Based Representation encoding 1

1

Delbruck, T., & Lichtsteiner, P. (2007, May). Fast sensory motor control based on event-based hybrid neuromorphic-procedural system. In 2007 IEEE International Symposium on Circuits and Systems (pp. 845-848). IEEE.

Parameters
  • data (numpy.ndarray) – See :py:mod: nucube.utils.ReadCSV

  • threshold (float) – Threshold to cut off spike detection.

_get_mean_sd_sample()[source]

Returns mean and standard deviation of absolute data.

Return type

(numpy.ndarray, numpy.ndarray)

Returns

mean, sd

_get_threshold()[source]

Returns threshold values for each feature of every sample.

Return type

ndarray

Returns

threshold

_get_training_element_difference()[source]

Returns row-by-row difference for each sample.

Return type

numpy.ndarray

Returns

row_diff

get_spike_time(offset=100)[source]

Merges the samples and returns the time at which the spike happens. Spike time always startes with 1 and increases with :param: offset.

Parameters

offset (int) – Shifting the spike index to the given number, if the first index is 0, then it will always be 1

Return type

list

Returns

Spike time with an offset.

get_spikes()[source]

Returns TBR spikes.

Return type

numpy.ndarray

Returns

spikes

>>> spikes = TBR()
>>> spikes.get_spikes()
    [[[0 0 0 ..., 0 0 0]
    [1 1 1 ..., 1 1 1]
    [0 0 1 ..., 1 0 1]
    ...,
    [0 0 0 ..., 1 0 0]
    [0 0 0 ..., 0 0 1]
    [0 0 0 ..., 0 0 0]]
    |
    [[0 0 0 ..., 0 0 0]
    [0 0 0 ..., 0 0 0]
    [0 1 0 ..., 0 1 1]
    ...,
    [0 0 0 ..., 0 0 0]
    [0 0 0 ..., 0 0 1]
    [1 0 1 ..., 0 0 1]]]