pub struct SgdConfig {
    pub lr: f32,
    pub momentum: Option<Momentum>,
    pub weight_decay: Option<WeightDecay>,
}
Expand description

Configuration of hyperparameters for Sgd.

Using different learning rate:

SgdConfig {
    lr: 1e-1,
    momentum: None,
    weight_decay: None,
};

Using classic momentum:

SgdConfig {
    lr: 1e-2,
    momentum: Some(Momentum::Classic(0.5)),
    weight_decay: None,
};

Using nesterov momentum:

SgdConfig {
    lr: 1e-3,
    momentum: Some(Momentum::Nesterov(0.25)),
    weight_decay: None,
};

Using L2 weight decay:

SgdConfig {
    lr: 1e-3,
    momentum: None,
    weight_decay: Some(WeightDecay::L2(1e-2)),
};

Using decoupled weight decay:

SgdConfig {
    lr: 1e-3,
    momentum: None,
    weight_decay: Some(WeightDecay::Decoupled(1e-2)),
};

Fields

lr: f32

Learning rate. Defaults to 1e-2

momentum: Option<Momentum>

Optional momentum. Defaults to None.

weight_decay: Option<WeightDecay>

Optional weight decay. Defaults to None.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. 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.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. 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.