pub struct GradientDescent<Input, Output, M: OptimizableModel<Input, Output>> {
pub cost_history: Vec<f64>,
/* private fields */
}Expand description
A standard gradient descent optimizer.
Gradient descent is an optim algorithm that iteratively adjusts parameters to minimize a cost function by moving in the direction of the steepest decrease in the cost function.
§Fields
learning_rate- The step size for each iteration of gradient descentepochs- The number of complete passes through the training datasetcost_history- Records the cost value after each parameter update
Fields§
§cost_history: Vec<f64>Implementations§
Source§impl<Input, Output, M: OptimizableModel<Input, Output>> GradientDescent<Input, Output, M>
impl<Input, Output, M: OptimizableModel<Input, Output>> GradientDescent<Input, Output, M>
Trait Implementations§
Source§impl<M: OptimizableModel<Matrix, Vector>> Optimizer<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, M> for GradientDescent<Matrix, Vector, M>
impl<M: OptimizableModel<Matrix, Vector>> Optimizer<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, M> for GradientDescent<Matrix, Vector, M>
Source§fn fit(
&mut self,
model: &mut M,
x: &Matrix,
y: &Vector,
) -> Result<(), ModelError>
fn fit( &mut self, model: &mut M, x: &Matrix, y: &Vector, ) -> Result<(), ModelError>
Fits the model to the training data using gradient descent algorithm.
This method updates the model parameters by computing gradients and adjusting the parameters in the direction that minimizes the cost function.
§Arguments
model- The machine learning model to optimizex- The input training datay- The expected output values
§Returns
Ok(())if optim completes successfullyErr(ModelError)if an error occurs during optim
Auto Trait Implementations§
impl<Input, Output, M> Freeze for GradientDescent<Input, Output, M>
impl<Input, Output, M> RefUnwindSafe for GradientDescent<Input, Output, M>
impl<Input, Output, M> Send for GradientDescent<Input, Output, M>
impl<Input, Output, M> Sync for GradientDescent<Input, Output, M>
impl<Input, Output, M> Unpin for GradientDescent<Input, Output, M>
impl<Input, Output, M> UnwindSafe for GradientDescent<Input, Output, M>
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> 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