pub trait UnifiedOptimizer<A: Float> {
// Required methods
fn config(&self) -> &OptimizerConfig<A>;
fn step_param<D: Dimension>(
&mut self,
param: &mut Parameter<A, D>,
) -> Result<()>
where A: ScalarOperand + Debug;
fn set_lr(&mut self, lr: A);
fn get_lr(&self) -> A;
fn state_dict(&self) -> HashMap<String, Vec<u8>>;
fn load_state_dict(
&mut self,
state_dict: HashMap<String, Vec<u8>>,
) -> Result<()>;
// Provided methods
fn step_params<D: Dimension>(
&mut self,
params: &mut [Parameter<A, D>],
) -> Result<()>
where A: ScalarOperand + Debug { ... }
fn zero_grad<D: Dimension>(&self, params: &mut [Parameter<A, D>]) { ... }
}
Expand description
Unified optimizer interface
Required Methods§
Sourcefn config(&self) -> &OptimizerConfig<A>
fn config(&self) -> &OptimizerConfig<A>
Get optimizer configuration
Sourcefn step_param<D: Dimension>(
&mut self,
param: &mut Parameter<A, D>,
) -> Result<()>where
A: ScalarOperand + Debug,
fn step_param<D: Dimension>(
&mut self,
param: &mut Parameter<A, D>,
) -> Result<()>where
A: ScalarOperand + Debug,
Update a single parameter
Provided Methods§
Sourcefn step_params<D: Dimension>(
&mut self,
params: &mut [Parameter<A, D>],
) -> Result<()>where
A: ScalarOperand + Debug,
fn step_params<D: Dimension>(
&mut self,
params: &mut [Parameter<A, D>],
) -> Result<()>where
A: ScalarOperand + Debug,
Update multiple parameters
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.