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.
Auto Trait Implementations§
impl Freeze for DeltaEncoderFixed
impl RefUnwindSafe for DeltaEncoderFixed
impl Send for DeltaEncoderFixed
impl Sync for DeltaEncoderFixed
impl Unpin for DeltaEncoderFixed
impl UnsafeUnpin for DeltaEncoderFixed
impl UnwindSafe for DeltaEncoderFixed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more