pub struct AdaptiveThresholdMoENeuron {
pub v: f64,
pub v_th: f64,
pub k: f64,
mean_abs_x: f64,
ema_alpha: f64,
}Expand description
Adaptive threshold spiking neuron matching the SpikingBrain architecture.
Converts activations into integer spike counts via data-dependent threshold, enabling addition-based event-driven computation with ~69% sparsity.
Exact equations from arXiv:2509.05276v2 (SpikingBrain Technical Report):
V_th(x) = (1/k) · mean(|x|) (adaptive threshold) v[t+1] = v[t] - V_th · s[t] + x[t+1] (membrane with soft reset) s_INT = round(v_T / V_th) (integer spike count)
In time-collapsed mode: v_T = x, s_INT = round(x / V_th). Parameter k controls the firing rate / sparsity trade-off.
Reference: SpikingBrain-1.0, arXiv:2509.05276v2, September 2025.
Fields§
§v: f64Membrane potential.
v_th: f64Current adaptive threshold.
k: f64Firing rate control parameter (higher k → lower threshold → more spikes).
mean_abs_x: f64Running EMA of |input| for threshold computation.
ema_alpha: f64EMA decay for mean estimation.
Implementations§
Source§impl AdaptiveThresholdMoENeuron
impl AdaptiveThresholdMoENeuron
pub fn new() -> Self
pub fn with_k(k: f64) -> Self
Sourcepub fn step(&mut self, current: f64) -> i32
pub fn step(&mut self, current: f64) -> i32
Returns integer spike count (0 or more) — not binary.
Implements: V_th = (1/k)·mean(|x|), s = round(v/V_th), soft reset v -= V_th·s.
Sourcepub fn step_collapsed(&mut self, activation: f64) -> i32
pub fn step_collapsed(&mut self, activation: f64) -> i32
Time-collapsed single-step mode: s_INT = round(x / V_th).
Sourcepub fn sparsity(&self) -> f64
pub fn sparsity(&self) -> f64
Current activation sparsity estimate (1 if below threshold, 0 if firing).
pub fn reset(&mut self)
Trait Implementations§
Source§impl Clone for AdaptiveThresholdMoENeuron
impl Clone for AdaptiveThresholdMoENeuron
Source§fn clone(&self) -> AdaptiveThresholdMoENeuron
fn clone(&self) -> AdaptiveThresholdMoENeuron
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AdaptiveThresholdMoENeuron
impl Debug for AdaptiveThresholdMoENeuron
Auto Trait Implementations§
impl Freeze for AdaptiveThresholdMoENeuron
impl RefUnwindSafe for AdaptiveThresholdMoENeuron
impl Send for AdaptiveThresholdMoENeuron
impl Sync for AdaptiveThresholdMoENeuron
impl Unpin for AdaptiveThresholdMoENeuron
impl UnsafeUnpin for AdaptiveThresholdMoENeuron
impl UnwindSafe for AdaptiveThresholdMoENeuron
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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