pub struct DeltaEncoderFixed { /* private fields */ }alloc only.Expand description
Delta spike encoder for fixed-point inputs.
Converts continuous-valued features (Q1.14 i16) into binary spike trains by detecting temporal changes exceeding per-feature thresholds.
§Layout
For n_features input features, the output has 2 * n_features channels:
- Channel
2*i= positive spike (feature increased) - Channel
2*i + 1= negative spike (feature decreased)
Implementations§
Source§impl DeltaEncoderFixed
impl DeltaEncoderFixed
Sourcepub fn new(n_features: usize, threshold: i16) -> Self
pub fn new(n_features: usize, threshold: i16) -> Self
Create a new delta encoder with a uniform threshold for all features.
§Arguments
n_features– number of raw input featuresthreshold– uniform spike threshold in Q1.14
Sourcepub fn new_per_feature(thresholds: Vec<i16>) -> Self
pub fn new_per_feature(thresholds: Vec<i16>) -> Self
Create a new delta encoder with per-feature thresholds.
§Arguments
thresholds– one threshold per input feature, in Q1.14
Sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Number of raw input features.
Sourcepub fn n_output_channels(&self) -> usize
pub fn n_output_channels(&self) -> usize
Number of output spike channels (always 2 * n_features).
Sourcepub fn encode(&mut self, input: &[i16], out_spikes: &mut [u8])
pub fn encode(&mut self, input: &[i16], out_spikes: &mut [u8])
Encode an input vector into a spike buffer.
The out_spikes buffer must have length >= 2 * n_features. It will be
filled with 0s and 1s: even indices for positive spikes, odd for negative.
On the very first call, no spikes are emitted (the encoder needs a previous value to compute deltas). The previous values are stored for the next call.
§Panics
Panics if input.len() != n_features or out_spikes.len() < 2 * n_features.