pub struct LBFGS<A: Float + ScalarOperand + Debug> { /* private fields */ }Expand description
L-BFGS optimizer
Implements the Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) algorithm. This is a quasi-Newton method that approximates the Hessian inverse using a limited amount of memory by storing only a few vectors from previous iterations.
§Examples
use scirs2_core::ndarray::Array1;
use optirs_core::optimizers::{LBFGS, Optimizer};
// Initialize parameters and gradients
let params = Array1::zeros(5);
let gradients = Array1::from_vec(vec![0.1, 0.2, -0.3, 0.0, 0.5]);
// Create an L-BFGS optimizer
let mut optimizer = LBFGS::new(1.0);
// Update parameters
let new_params = optimizer.step(¶ms, &gradients).unwrap();Implementations§
Source§impl<A: Float + ScalarOperand + Debug + Send + Sync> LBFGS<A>
impl<A: Float + ScalarOperand + Debug + Send + Sync> LBFGS<A>
Sourcepub fn new(learning_rate: A) -> Self
pub fn new(learning_rate: A) -> Self
Creates a new L-BFGS optimizer with the given learning rate
§Arguments
learning_rate- The learning rate for parameter updates
Sourcepub fn new_with_config(
learning_rate: A,
history_size: usize,
tolerance_grad: A,
c1: A,
c2: A,
max_ls: usize,
) -> Self
pub fn new_with_config( learning_rate: A, history_size: usize, tolerance_grad: A, c1: A, c2: A, max_ls: usize, ) -> Self
Creates a new L-BFGS optimizer with full configuration
§Arguments
learning_rate- The learning rate for parameter updateshistory_size- Number of past gradients/steps to store (default: 100)tolerance_grad- Gradient norm tolerance for convergence (default: 1e-7)c1- Wolfe line search parameter for Armijo condition (default: 1e-4)c2- Wolfe line search parameter for curvature condition (default: 0.9)max_ls- Maximum line search iterations (default: 25)
Sourcepub fn learning_rate(&self) -> A
pub fn learning_rate(&self) -> A
Gets the current learning rate
Trait Implementations§
Source§impl<A, D> Optimizer<A, D> for LBFGS<A>
impl<A, D> Optimizer<A, D> for LBFGS<A>
Source§fn step(
&mut self,
params: &Array<A, D>,
gradients: &Array<A, D>,
) -> Result<Array<A, D>>
fn step( &mut self, params: &Array<A, D>, gradients: &Array<A, D>, ) -> Result<Array<A, D>>
Updates parameters using the given gradients Read more
Source§fn get_learning_rate(&self) -> A
fn get_learning_rate(&self) -> A
Gets the current learning rate
Source§fn set_learning_rate(&mut self, learning_rate: A)
fn set_learning_rate(&mut self, learning_rate: A)
Sets a new learning rate
Auto Trait Implementations§
impl<A> Freeze for LBFGS<A>where
A: Freeze,
impl<A> RefUnwindSafe for LBFGS<A>where
A: RefUnwindSafe,
impl<A> Send for LBFGS<A>where
A: Send,
impl<A> Sync for LBFGS<A>where
A: Sync,
impl<A> Unpin for LBFGS<A>where
A: Unpin,
impl<A> UnwindSafe for LBFGS<A>where
A: UnwindSafe + RefUnwindSafe,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.