pub struct SimpleMLP {
pub hidden: DenseLayer,
pub output: DenseLayer,
}Expand description
A simple two-layer MLP for student model
Fields§
Hidden layer
output: DenseLayerOutput layer
Implementations§
Source§impl SimpleMLP
impl SimpleMLP
Sourcepub fn new(
input_size: usize,
hidden_size: usize,
output_size: usize,
seed: u64,
) -> Self
pub fn new( input_size: usize, hidden_size: usize, output_size: usize, seed: u64, ) -> Self
Creates a new simple MLP
Sourcepub fn forward_with_cache(&self, input: &[f32]) -> (Vec<f32>, ForwardCache)
pub fn forward_with_cache(&self, input: &[f32]) -> (Vec<f32>, ForwardCache)
Forward pass with cached activations for backprop
Sourcepub fn backward(
&self,
grad_output: &[f32],
cache: &ForwardCache,
) -> MLPGradients
pub fn backward( &self, grad_output: &[f32], cache: &ForwardCache, ) -> MLPGradients
Backward pass computing all gradients
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Total number of parameters
Sourcepub fn get_params(&self) -> Vec<f32>
pub fn get_params(&self) -> Vec<f32>
Get all parameters as flat vector
Sourcepub fn set_params(&mut self, params: &[f32])
pub fn set_params(&mut self, params: &[f32])
Set parameters from flat vector
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimpleMLP
impl RefUnwindSafe for SimpleMLP
impl Send for SimpleMLP
impl Sync for SimpleMLP
impl Unpin for SimpleMLP
impl UnsafeUnpin for SimpleMLP
impl UnwindSafe for SimpleMLP
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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