Struct juice::solver::SolverConfig

source ·
pub struct SolverConfig {
Show 13 fields pub name: String, pub network: LayerConfig, pub objective: LayerConfig, pub solver: SolverKind, pub minibatch_size: usize, pub lr_policy: LRPolicy, pub base_lr: f32, pub gamma: f32, pub stepsize: usize, pub clip_gradients: Option<f32>, pub weight_decay: Option<f32>, pub regularization_method: Option<RegularizationMethod>, pub momentum: f32,
}
Expand description

Configuration for a Solver

Fields§

§name: String

Name of the solver.

§network: LayerConfig

The [LayerConfig][1] that is used to initialize the network. [1]: ../layer/struct.LayerConfig.html

§objective: LayerConfig

The [LayerConfig][1] that is used to initialize the objective. [1]: ../layer/struct.LayerConfig.html

§solver: SolverKind

The [Solver implementation][1] to be used. [1]: ../solvers/index.html

§minibatch_size: usize

Accumulate gradients over minibatch_size instances.

Default: 1

§lr_policy: LRPolicy

The learning rate policy to be used.

Default: Fixed

§base_lr: f32

The base learning rate.

Default: 0.01

§gamma: f32

gamma as used in the calculation of most learning rate policies.

Default: 0.1

§stepsize: usize

The stepsize used in Step and Sigmoid learning policies.

Default: 10

§clip_gradients: Option<f32>

The threshold for clipping gradients.

Gradient values will be scaled to their L2 norm of length clip_gradients if their L2 norm is larger than clip_gradients. If set to None gradients will not be clipped.

Default: None

§weight_decay: Option<f32>

The global [weight decay][1] multiplier for [regularization][2]. [1]: http://www.alglib.net/dataanalysis/improvinggeneralization.php#header3 [2]: https://cs231n.github.io/neural-networks-2/#reg

Regularization can prevent overfitting.

If set to None no regularization will be performed.

§regularization_method: Option<RegularizationMethod>

The method of [regularization][1] to use. [1]: https://cs231n.github.io/neural-networks-2/#reg

There are different methods for regularization. The two most common ones are [L1 regularization][1] and [L2 regularization][1].

See RegularizationMethod for all implemented methods.

Currently only L2 regularization is implemented. See Issue #23.

§momentum: f32

The [momentum][1] multiplier for [SGD solvers][2]. [1]: https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum [2]: ../solvers/sgd/index.html

For more information see [SGD with momentum][3] [3]: ../solvers/sgd/momentum/index.html

The value should always be between 0 and 1 and dictates how much of the previous gradient update will be added to the current one.

Default: 0

Implementations§

source§

impl SolverConfig

source

pub fn get_learning_rate(&self, iter: usize) -> f32

Return the learning rate for a supplied iteration.

The way the learning rate is calculated depends on the configured LRPolicy.

Used by the Solver to calculate the learning rate for the current iteration. The calculated learning rate has a different effect on training dependent on what type of Solver you are using.

Trait Implementations§

source§

impl Clone for SolverConfig

source§

fn clone(&self) -> SolverConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SolverConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for SolverConfig

source§

fn default() -> SolverConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V