Skip to main content

SelectiveSSM

Struct SelectiveSSM 

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

Mamba-style selective state space model.

The selective mechanism computes input-dependent B, C, and Delta at each timestep, enabling the model to dynamically control what information is stored in and retrieved from the hidden state.

§Dimensions

  • d_in – input/output dimension (number of channels)
  • n_state – hidden state dimension per channel (N)
  • Total hidden state size: d_in * n_state

§Weight Shapes

WeightShapePurpose
w_deltad_inProjects input to scalar step size
w_bN x d_inProjects input to state-input coupling
w_cN x d_inProjects input to state-output coupling
d_skipd_inSkip connection weights
log_aNFixed state transition (always negative after exp)

§Example

use irithyll_core::ssm::selective::SelectiveSSM;
use irithyll_core::ssm::SSMLayer;

let mut ssm = SelectiveSSM::new(4, 8, 42);
let output = ssm.forward(&[1.0, 2.0, 3.0, 4.0]);
assert_eq!(output.len(), 4);

Implementations§

Source§

impl SelectiveSSM

Source

pub fn new(d_in: usize, n_state: usize, seed: u64) -> Self

Create a new selective SSM with random weight initialization.

Weights are initialized from a small normal distribution (scale 0.01) using the provided seed for reproducibility. A is initialized via the Mamba strategy (A_n = -(n+1)).

§Arguments
  • d_in – input/output dimension (number of channels)
  • n_state – hidden state dimension per channel (N)
  • seed – random seed for weight initialization
§Example
use irithyll_core::ssm::selective::SelectiveSSM;

let ssm = SelectiveSSM::new(4, 16, 42);
Source

pub fn d_in(&self) -> usize

Get the input/output dimension.

Source

pub fn n_state(&self) -> usize

Get the number of state dimensions per channel.

Trait Implementations§

Source§

impl SSMLayer for SelectiveSSM

Source§

fn forward(&mut self, input: &[f64]) -> Vec<f64>

Process one input timestep and return the output vector. Read more
Source§

fn state(&self) -> &[f64]

Get a reference to the current hidden state.
Source§

fn output_dim(&self) -> usize

Output dimension of this SSM layer.
Source§

fn reset(&mut self)

Reset hidden state to zeros, as if no data has been seen.

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.