pub struct MlpProjector {
pub in_dim: usize,
pub hidden_dim: usize,
pub out_dim: usize,
pub w1: Vec<f32>,
pub b1: Vec<f32>,
pub w2: Vec<f32>,
pub b2: Vec<f32>,
}Expand description
2-layer MLP projection head.
Fields§
§in_dim: usizeInput dim.
Hidden dim.
out_dim: usizeOutput (projection) dim.
w1: Vec<f32>First layer weights [hidden × in] (row-major).
b1: Vec<f32>First layer bias [hidden].
w2: Vec<f32>Second layer weights [out × hidden].
b2: Vec<f32>Second layer bias [out].
Implementations§
Source§impl MlpProjector
impl MlpProjector
Sourcepub fn new(
in_dim: usize,
hidden_dim: usize,
out_dim: usize,
rng: &mut LcgRng,
) -> SslResult<Self>
pub fn new( in_dim: usize, hidden_dim: usize, out_dim: usize, rng: &mut LcgRng, ) -> SslResult<Self>
Sourcepub fn forward(&self, x: &[f32]) -> SslResult<Vec<f32>>
pub fn forward(&self, x: &[f32]) -> SslResult<Vec<f32>>
Forward pass on a single feature vector [in_dim] → [out_dim].
§Errors
SslError::DimensionMismatch if x.len() != self.in_dim.
Sourcepub fn forward_batch(&self, x: &[f32], n: usize) -> SslResult<Vec<f32>>
pub fn forward_batch(&self, x: &[f32], n: usize) -> SslResult<Vec<f32>>
Forward pass on a batch [N × in_dim] → [N × out_dim].
§Errors
SslError::DimensionMismatch if x.len() != n*in_dim.
Trait Implementations§
Source§impl Clone for MlpProjector
impl Clone for MlpProjector
Source§fn clone(&self) -> MlpProjector
fn clone(&self) -> MlpProjector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MlpProjector
impl RefUnwindSafe for MlpProjector
impl Send for MlpProjector
impl Sync for MlpProjector
impl Unpin for MlpProjector
impl UnsafeUnpin for MlpProjector
impl UnwindSafe for MlpProjector
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