pub struct PyTorchSGD { /* private fields */ }Expand description
PyTorch-compatible SGD optimizer
Implementations§
Source§impl PyTorchSGD
impl PyTorchSGD
Sourcepub fn new(
params: Vec<PyTorchParamGroup>,
lr: f64,
momentum: f64,
dampening: f64,
weight_decay: f64,
nesterov: bool,
) -> Result<Self>
pub fn new( params: Vec<PyTorchParamGroup>, lr: f64, momentum: f64, dampening: f64, weight_decay: f64, nesterov: bool, ) -> Result<Self>
Create new PyTorch-compatible SGD optimizer
Sourcepub fn from_params(
params: impl IntoIterator<Item = (String, Tensor)>,
) -> Result<Self>
pub fn from_params( params: impl IntoIterator<Item = (String, Tensor)>, ) -> Result<Self>
Create with default parameters
Trait Implementations§
Source§impl Debug for PyTorchSGD
impl Debug for PyTorchSGD
Source§impl PyTorchOptimizer for PyTorchSGD
impl PyTorchOptimizer for PyTorchSGD
Source§fn param_groups(&self) -> &[PyTorchParamGroup]
fn param_groups(&self) -> &[PyTorchParamGroup]
Get parameter groups
Source§fn param_groups_mut(&mut self) -> &mut [PyTorchParamGroup]
fn param_groups_mut(&mut self) -> &mut [PyTorchParamGroup]
Get mutable parameter groups
Source§fn state_dict(&self) -> PyTorchOptimizerState
fn state_dict(&self) -> PyTorchOptimizerState
Get optimizer state
Source§fn load_state_dict(&mut self, state: PyTorchOptimizerState) -> Result<()>
fn load_state_dict(&mut self, state: PyTorchOptimizerState) -> Result<()>
Load optimizer state
Source§fn step(&mut self, closure: Option<Box<dyn Fn() -> f64>>) -> Result<Option<f64>>
fn step(&mut self, closure: Option<Box<dyn Fn() -> f64>>) -> Result<Option<f64>>
Perform optimization step
Source§fn add_param_group(&mut self, param_group: PyTorchParamGroup) -> Result<()>
fn add_param_group(&mut self, param_group: PyTorchParamGroup) -> Result<()>
Add parameter group
Source§fn defaults(&self) -> PyTorchParamGroup
fn defaults(&self) -> PyTorchParamGroup
Get defaults
Auto Trait Implementations§
impl Freeze for PyTorchSGD
impl RefUnwindSafe for PyTorchSGD
impl Send for PyTorchSGD
impl Sync for PyTorchSGD
impl Unpin for PyTorchSGD
impl UnwindSafe for PyTorchSGD
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> 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