Skip to main content

Feast

Struct Feast 

Source
pub struct Feast { /* private fields */ }
Expand description

A FEAST feature-extractor model. Build with Feast::new, adapt online with Feast::fit (repeatable across recordings/epochs), then map events to feature ids with Feast::transform.

Implementations§

Source§

impl Feast

Source

pub fn new(config: FeastConfig) -> Result<Self, FeastError>

Builds a model with random unit-hypersphere feature weights and random thresholds in [0, 1), seeded by config.seed. Fails if any parameter is out of range.

Source

pub fn from_state( config: FeastConfig, weights: Vec<f32>, thresholds: Vec<f32>, ) -> Result<Self, FeastError>

Rehydrates a model from saved state (used by the Python save/load round-trip). weights is the flat [bank][feature][dim] array and thresholds the flat [bank][feature] array; both must match config’s implied sizes.

Source

pub fn fit(&mut self, stream: &EventStream, epochs: usize) -> f64

Trains the model on stream for epochs passes (each a fresh time surface, weights and thresholds carried over), adapting weights and thresholds online. Returns the miss rate of the final epoch — the fraction of in-bounds events that matched no feature, which settles to a low steady state (a few percent in the paper) as the network converges.

Source

pub fn transform(&self, stream: &EventStream) -> Vec<i32>

Maps each event to the id of its nearest feature (smallest cosine distance), ignoring thresholds — the paper’s inference rule. Returns one id per input event, aligned to the stream; events too close to the border to extract a patch get -1. Ids are global: population b, feature fb * n_features + f, so per-polarity OFF ids start at n_features. Does not modify the model.

Source

pub fn histogram(&self, stream: &EventStream) -> Vec<u32>

Pooled feature-event counts over stream (the classifier input in the paper): a histogram of length n_features_total counting how many events each feature won under Self::transform.

Source

pub fn weights(&self) -> &[f32]

The learned feature weights, flat [bank][feature][dim] (reshape to (n_features_total, patch, patch) for the per-feature patch images).

Source

pub fn thresholds(&self) -> &[f32]

The current selection thresholds, flat [bank][feature].

Source

pub fn n_features_total(&self) -> usize

Total feature count across populations (banks * n_features).

Source

pub fn config(&self) -> &FeastConfig

Source

pub fn missed_rate(&self) -> f64

Miss rate recorded by the most recent Self::fit (0 before any training).

Trait Implementations§

Source§

impl Clone for Feast

Source§

fn clone(&self) -> Feast

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Feast

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Feast

§

impl RefUnwindSafe for Feast

§

impl Send for Feast

§

impl Sync for Feast

§

impl Unpin for Feast

§

impl UnsafeUnpin for Feast

§

impl UnwindSafe for Feast

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V