pub struct SparseSgd { /* private fields */ }Expand description
Sparse SGD optimizer over a 1-D dense parameter vector.
With momentum == 0 and weight_decay == 0 this is the canonical sparse
update params[i] -= lr * grad[i], touching only the non-zero coordinates
and leaving every other coordinate bit-identical.
Implementations§
Source§impl SparseSgd
impl SparseSgd
Sourcepub fn new(config: SparseSgdConfig) -> Self
pub fn new(config: SparseSgdConfig) -> Self
Create a new optimizer. State (if momentum is used) is allocated lazily.
Sourcepub fn config(&self) -> &SparseSgdConfig
pub fn config(&self) -> &SparseSgdConfig
Immutable view of the configuration.
Sourcepub fn step(
&mut self,
params: &mut Array1<f64>,
grad: &CooGradient,
) -> Result<(), GpuOptimError>
pub fn step( &mut self, params: &mut Array1<f64>, grad: &CooGradient, ) -> Result<(), GpuOptimError>
Perform one sparse SGD update in place, touching only the coordinates
present in grad.
§Errors
Returns GpuOptimError::DimensionMismatch on dimension disagreement and
propagates gradient validation errors.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SparseSgd
impl RefUnwindSafe for SparseSgd
impl Send for SparseSgd
impl Sync for SparseSgd
impl Unpin for SparseSgd
impl UnsafeUnpin for SparseSgd
impl UnwindSafe for SparseSgd
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more