pub struct LinearModel { /* private fields */ }Expand description
A simple linear model for testing and demonstration.
Implementations§
Source§impl LinearModel
impl LinearModel
Sourcepub fn xavier_init(&mut self)
pub fn xavier_init(&mut self)
Initialize parameters with Xavier/Glorot uniform initialization.
Sourcepub fn output_dim(&self) -> usize
pub fn output_dim(&self) -> usize
Get output dimension.
Trait Implementations§
Source§impl Clone for LinearModel
impl Clone for LinearModel
Source§fn clone(&self) -> LinearModel
fn clone(&self) -> LinearModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearModel
impl Debug for LinearModel
Source§impl Model for LinearModel
impl Model for LinearModel
Source§fn forward(
&self,
input: &ArrayView<'_, f64, Ix2>,
) -> TrainResult<Array<f64, Ix2>>
fn forward( &self, input: &ArrayView<'_, f64, Ix2>, ) -> TrainResult<Array<f64, Ix2>>
Perform a forward pass through the model. Read more
Source§fn backward(
&self,
input: &ArrayView<'_, f64, Ix2>,
grad_output: &ArrayView<'_, f64, Ix2>,
) -> TrainResult<HashMap<String, Array<f64, Ix2>>>
fn backward( &self, input: &ArrayView<'_, f64, Ix2>, grad_output: &ArrayView<'_, f64, Ix2>, ) -> TrainResult<HashMap<String, Array<f64, Ix2>>>
Perform a backward pass to compute gradients. Read more
Source§fn parameters(&self) -> &HashMap<String, Array<f64, Ix2>>
fn parameters(&self) -> &HashMap<String, Array<f64, Ix2>>
Get a reference to the model’s parameters.
Source§fn parameters_mut(&mut self) -> &mut HashMap<String, Array<f64, Ix2>>
fn parameters_mut(&mut self) -> &mut HashMap<String, Array<f64, Ix2>>
Get a mutable reference to the model’s parameters.
Source§fn set_parameters(&mut self, parameters: HashMap<String, Array<f64, Ix2>>)
fn set_parameters(&mut self, parameters: HashMap<String, Array<f64, Ix2>>)
Set the model’s parameters.
Source§fn reset_parameters(&mut self)
fn reset_parameters(&mut self)
Reset model parameters (optional, for retraining).
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the number of parameters in the model.
Source§fn load_state_dict(
&mut self,
state: HashMap<String, Vec<f64>>,
) -> TrainResult<()>
fn load_state_dict( &mut self, state: HashMap<String, Vec<f64>>, ) -> TrainResult<()>
Load model state from a dictionary.
Auto Trait Implementations§
impl Freeze for LinearModel
impl RefUnwindSafe for LinearModel
impl Send for LinearModel
impl Sync for LinearModel
impl Unpin for LinearModel
impl UnsafeUnpin for LinearModel
impl UnwindSafe for LinearModel
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> 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