Skip to main content

DeltaEncoderFixed

Struct DeltaEncoderFixed 

Source
pub struct DeltaEncoderFixed { /* private fields */ }
Available on crate feature 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

Source

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 features
  • threshold – uniform spike threshold in Q1.14
Source

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
Source

pub fn n_features(&self) -> usize

Number of raw input features.

Source

pub fn n_output_channels(&self) -> usize

Number of output spike channels (always 2 * n_features).

Source

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.

Source

pub fn reset(&mut self)

Reset the encoder to its initial state.

The next call to encode will produce no spikes (warmup step).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.