Import
[batch, T, n_features] with values in .
enc.rate_encode
Encodes real-valued input as a Poisson spike process over T timesteps.
Behavior
Each input value
x[b, i] is treated as a probability: at each timestep t, neuron i fires with probability x[b, i]. The output is a Bernoulli sample over [batch, T, n_features].
enc.temporal_contrast
Encodes a temporal signal (audio, sensor) using temporal contrast: a spike is emitted when the signal changes by more than a threshold, with separate ON (increase) and OFF (decrease) channels.
Output channels
The output has
2 × n_features channels:
- Channels
0..n: ON events (signal increased by ≥ threshold) - Channels
n..2n: OFF events (signal decreased by ≥ threshold)
enc.cochlear_encode
Encodes an audio waveform through a bank of bandpass filters (cochlear model) into a spike raster. Produces the SHD-compatible encoding used in the keyword-spotting tutorial.
Notes
- Frequency bands are spaced logarithmically between
freq_minandfreq_max. - Each channel fires when the bandpass-filtered signal exceeds its local threshold (set at 2σ from the silence baseline).
- This encoder is consistent with the SHD dataset’s cochlear model but is independently implemented.
enc.SHDLoader
A dataset loader that returns pre-encoded SHD spike rasters directly.SHDLoader downloads and caches the dataset from the official source on first use. It returns pre-binned spike rasters in the THRINDEX-native format.