Skip to main content

Module parameter

Module parameter 

Source
Expand description

Parameter trait and five built-in parameter types.

The Parameter trait provides a unified way to define search-space dimensions and sample values from a Trial. Five implementations cover the most common hyperparameter types:

TypeSampled valueTypical use
FloatParamf64Learning rate, dropout probability
IntParami64Layer count, batch size
CategoricalParamT: CloneOptimizer name, activation function
BoolParamboolFeature toggle
EnumParamT: CategoricalTyped enum variant selection

All five types support .name() for a human-readable label and .suggest(&mut trial) as a shorthand for trial.suggest_param(&param).

§Example

use optimizer::Trial;
use optimizer::parameter::{BoolParam, FloatParam, IntParam, Parameter};

let mut trial = Trial::new(0);

let lr = FloatParam::new(1e-5, 1e-1)
    .log_scale()
    .name("learning_rate")
    .suggest(&mut trial)
    .unwrap();
let layers = IntParam::new(1, 10)
    .name("n_layers")
    .suggest(&mut trial)
    .unwrap();
let dropout = BoolParam::new()
    .name("use_dropout")
    .suggest(&mut trial)
    .unwrap();

Re-exports§

pub use crate::param::ParamValue;

Structs§

BoolParam
A boolean parameter (equivalent to a two-choice categorical: false / true).
CategoricalParam
A categorical parameter that selects from a list of choices.
EnumParam
A parameter that selects from the variants of an enum implementing Categorical.
FloatParam
A floating-point parameter with optional log-scale and step size.
IntParam
An integer parameter with optional log-scale and step size.
ParamId
A unique identifier for a parameter instance.

Traits§

Categorical
Map an enum type to sequential indices for use as a categorical parameter.
Parameter
Define a parameter type that can be suggested by a Trial.