Skip to main content

SpikeNetFixed

Struct SpikeNetFixed 

Source
pub struct SpikeNetFixed { /* private fields */ }
Available on crate feature alloc only.
Expand description

Complete spiking neural network with e-prop online learning.

Manages all neuron state, synaptic weights, eligibility traces, and spike encoding. After construction, memory is fixed – no further allocations occur during forward or train_step.

§Thread Safety

SpikeNetFixed is Send + Sync because it contains only Vec<T> and primitive fields with no interior mutability.

Implementations§

Source§

impl SpikeNetFixed

Source

pub fn new(config: SpikeNetFixedConfig) -> Self

Create a new SpikeNetFixed with the given configuration.

Allocates all internal buffers and initializes weights from the PRNG. No further allocations occur during operation.

Source

pub fn forward(&mut self, input_i16: &[i16])

Run one forward timestep without learning.

Encodes input into spikes, updates hidden neuron states, and advances the readout. Does NOT update weights or eligibility traces.

§Arguments
  • input_i16 – raw input features in Q1.14, length must equal config.n_input
Source

pub fn train_step(&mut self, input_i16: &[i16], target_i16: &[i16])

Run one forward + learning timestep (e-prop three-factor rule).

Performs a forward pass, then computes error signals and updates all weights using the e-prop learning rule.

§Arguments
  • input_i16 – raw input features in Q1.14
  • target_i16 – target values in Q1.14, length must equal config.n_output
Source

pub fn predict_raw(&self) -> Vec<i32>

Get raw readout membrane potentials as i32.

Returns a reference to an internal buffer that is updated on each forward or train_step call.

Source

pub fn predict_f64(&self, output_scale: f64) -> f64

Get the first readout’s membrane potential, dequantized to f64.

§Arguments
  • output_scale – scaling factor (typically 1.0 / Q14_ONE as f64)
Source

pub fn predict_all_f64(&self, output_scale: f64) -> Vec<f64>

Get all readout membrane potentials, dequantized to f64.

§Arguments
  • output_scale – scaling factor per output
Source

pub fn n_samples_seen(&self) -> u64

Number of training samples seen.

Source

pub fn config(&self) -> &SpikeNetFixedConfig

Reference to the network configuration.

Source

pub fn n_hidden(&self) -> usize

Number of hidden neurons.

Source

pub fn n_input_encoded(&self) -> usize

Number of encoded input channels (2 * n_input).

Source

pub fn hidden_spikes(&self) -> &[u8]

Get current hidden spike vector.

Source

pub fn hidden_membrane(&self) -> &[i16]

Get current hidden membrane potentials.

Source

pub fn memory_bytes(&self) -> usize

Compute total memory usage in bytes.

Counts all Vec contents plus struct overhead.

Source

pub fn reset(&mut self)

Reset all network state (neuron potentials, traces, readout) to zero.

Weights are re-initialized from the original seed. The network behaves as if freshly constructed after calling reset.

Trait Implementations§

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.