pub trait Optimizer<M, D: Storage<E>, E: Dtype> {
// Required method
fn update(
&mut self,
module: &mut M,
gradients: &Gradients<E, D>
) -> Result<(), OptimizerUpdateError<D::Err>>;
}
Expand description
All optimizers must implement the update function, which takes a M
and updates all of its parameters.
Notes
-
Update takes ownership of Gradients, so update cannot be called with the same gradients object.
-
Optimizer itself is generic over M, not the update method. This means a single optimizer object can only work on objects of type
M
. This also requires you to specify the model up front for the optimizer.