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:
| Type | Sampled value | Typical use |
|---|---|---|
FloatParam | f64 | Learning rate, dropout probability |
IntParam | i64 | Layer count, batch size |
CategoricalParam | T: Clone | Optimizer name, activation function |
BoolParam | bool | Feature toggle |
EnumParam | T: Categorical | Typed enum variant selection |
All five types support .name() for a human-readable label and
.suggest(&mut trial) as a shorthand for trial.suggest_param(¶m).
§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§
- Bool
Param - A boolean parameter (equivalent to a two-choice categorical:
false/true). - Categorical
Param - A categorical parameter that selects from a list of choices.
- Enum
Param - A parameter that selects from the variants of an enum implementing
Categorical. - Float
Param - 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.