pub struct LBFGS { /* private fields */ }Expand description
Implementations§
Source§impl LBFGS
impl LBFGS
Sourcepub fn to_record(&self) -> OptimizerRecord
pub fn to_record(&self) -> OptimizerRecord
Decompose the optimizer state into a serializable OptimizerRecord (burnpack format).
L-BFGS keeps a single global state rather than per-parameter state, so its tensors are
named directly (e.g. history_s.0) and carry no parameter id.
Sourcepub fn load_record(self, record: OptimizerRecord) -> Self
pub fn load_record(self, record: OptimizerRecord) -> Self
Load the optimizer state from an OptimizerRecord.
State tensors are materialized on the default device; the state is migrated to the gradient
device on the next step, so no device argument is needed.
Sourcepub fn into_bytes(&self) -> Result<Bytes, RecordError>
pub fn into_bytes(&self) -> Result<Bytes, RecordError>
Serialize the optimizer state to an in-memory burnpack byte buffer.
Sourcepub fn from_bytes(self, bytes: Bytes) -> Result<Self, RecordError>
pub fn from_bytes(self, bytes: Bytes) -> Result<Self, RecordError>
Load the optimizer state from an in-memory burnpack byte buffer.
Sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), RecordError>
Available on crate feature std only.
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<(), RecordError>
std only.Save the optimizer state to a burnpack file on disk.
Sourcepub fn load<P: AsRef<Path>>(self, path: P) -> Result<Self, RecordError>
Available on crate feature std only.
pub fn load<P: AsRef<Path>>(self, path: P) -> Result<Self, RecordError>
std only.Load the optimizer state from a burnpack file on disk.
Sourcepub fn step<M, F>(
&mut self,
lr: LearningRate,
module: M,
closure: F,
) -> (M, f64)
pub fn step<M, F>( &mut self, lr: LearningRate, module: M, closure: F, ) -> (M, f64)
A single optimization step for any tensor that represents the parameters of a model.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LBFGS
impl RefUnwindSafe for LBFGS
impl Send for LBFGS
impl Sync for LBFGS
impl Unpin for LBFGS
impl UnsafeUnpin for LBFGS
impl UnwindSafe for LBFGS
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
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> ⓘ
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> ⓘ
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