Struct drug::Optimizer

source ·
pub struct Optimizer {
    pub learning_rate: f32,
    pub beta_momentum: f32,
    pub beta_magnitude: f32,
    pub epsilon: f32,
    /* private fields */
}
Expand description

Here is a good blog that explains various optimizers. Currently only SGD, RMSProp, Adam, and SGD-with-momentum are implemented. The Optimizerstruct builds and holds OptimizerInstances which hold runtime information about every parameter that’s being optimized. If beta_momentum or beta_magnitude are set to zero, then the optimizer does not keep momentum and magnitude correction information information about parameters. epsilon is added to denominators to avoid divide by zero errors.

no beta_momentumbeta_momentum
no beta_magnitudevanilla SGDSGD with momentum
beta_magnitudeRMSPropAdam

Fields§

§learning_rate: f32§beta_momentum: f32§beta_magnitude: f32§epsilon: f32

Implementations§

Vanilla stochastic gradient descent with no added fluff.

SGD with a momentum component. Add the geometric average of past gradients to the parameter instead of the gradient itself. This averaging dampens the stochasticity of the stochastic gradient descent.

SGD with a magnitude component. Rescale gradients by dividing by the geometric mean of previous gradients squared. Parameters with frequent large gradients will see those gradients shrink while parameters with sparse gradients will have their gradients grow.

Adam (Adaptive Moment Estimation) Combines the momentum component from momentum and the magnitude component from rmsprop.

Apply gradient

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.