pub struct SurrogateLif {
pub lif: FixedPointLif,
pub surrogate: SurrogateType,
membrane_trace: Vec<(f32, f32)>,
}Expand description
LIF neuron with surrogate gradient support.
Fields§
§lif: FixedPointLif§surrogate: SurrogateType§membrane_trace: Vec<(f32, f32)>Implementations§
Source§impl SurrogateLif
impl SurrogateLif
Sourcepub fn new(
data_width: u32,
fraction: u32,
v_rest: i16,
v_reset: i16,
v_threshold: i16,
refractory_period: i32,
surrogate: SurrogateType,
) -> Self
pub fn new( data_width: u32, fraction: u32, v_rest: i16, v_reset: i16, v_threshold: i16, refractory_period: i32, surrogate: SurrogateType, ) -> Self
Construct a surrogate-enabled fixed-point LIF neuron.
Sourcepub fn forward(
&mut self,
leak_k: i16,
gain_k: i16,
i_t: i16,
noise_in: i16,
) -> (i32, i16)
pub fn forward( &mut self, leak_k: i16, gain_k: i16, i_t: i16, noise_in: i16, ) -> (i32, i16)
Forward LIF step while caching trace for backward pass.
Sourcepub fn backward(&mut self, grad_output: f32) -> Result<f32, String>
pub fn backward(&mut self, grad_output: f32) -> Result<f32, String>
Backward pass through last cached membrane value.
Sourcepub fn clear_trace(&mut self)
pub fn clear_trace(&mut self)
Clear stored membrane trace.
Auto Trait Implementations§
impl Freeze for SurrogateLif
impl RefUnwindSafe for SurrogateLif
impl Send for SurrogateLif
impl Sync for SurrogateLif
impl Unpin for SurrogateLif
impl UnsafeUnpin for SurrogateLif
impl UnwindSafe for SurrogateLif
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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