pub struct HyperparameterOptimizer<T: Float> { /* private fields */ }Expand description
Hyperparameter optimizer for NAS and discovered architectures
Implementations§
Source§impl<T: Float + Default + Clone + Send + Sync> HyperparameterOptimizer<T>
impl<T: Float + Default + Clone + Send + Sync> HyperparameterOptimizer<T>
Sourcepub fn new(
search_space: HyperparameterSpace<T>,
strategy: OptimizationStrategy,
) -> Self
pub fn new( search_space: HyperparameterSpace<T>, strategy: OptimizationStrategy, ) -> Self
Create a new hyperparameter optimizer, seeded from OS entropy.
Sourcepub fn with_seed(
search_space: HyperparameterSpace<T>,
strategy: OptimizationStrategy,
seed: u64,
) -> Self
pub fn with_seed( search_space: HyperparameterSpace<T>, strategy: OptimizationStrategy, seed: u64, ) -> Self
Create a fully reproducible optimizer.
Sourcepub fn suggest_configuration(
&mut self,
) -> Result<HyperparameterConfiguration<T>>
pub fn suggest_configuration( &mut self, ) -> Result<HyperparameterConfiguration<T>>
Generate the next hyperparameter configuration to evaluate.
Returns an error for a strategy this module does not implement
(OptimizationStrategy::ParticleSwarm, SuccessiveHalving, Hyperband,
BOHB) rather than silently performing random search, and for a search
space that declares no parameters at all.
The model-based strategies (Bayesian, TPE, Evolutionary) need a
random initial design first. During that phase they sample from the prior
and set HyperparameterOptimizer::last_strategy_used to
OptimizationStrategy::Random, so the caller can see which algorithm
actually produced the suggestion.
Sourcepub fn last_strategy_used(&self) -> OptimizationStrategy
pub fn last_strategy_used(&self) -> OptimizationStrategy
Which strategy produced the most recent suggestion. Differs from
HyperparameterOptimizer::strategy exactly while a model-based strategy
is still running its random initial design.
Sourcepub fn strategy(&self) -> OptimizationStrategy
pub fn strategy(&self) -> OptimizationStrategy
The configured strategy.
Sourcepub fn grid_resolution(&self) -> usize
pub fn grid_resolution(&self) -> usize
Number of points per continuous grid axis.
Sourcepub fn set_grid_resolution(&mut self, resolution: usize)
pub fn set_grid_resolution(&mut self, resolution: usize)
Set the number of points per continuous grid axis.
Sourcepub fn grid_size(&self) -> Option<usize>
pub fn grid_size(&self) -> Option<usize>
Total number of distinct grid points, or None if the product overflows.
Sourcepub fn set_acquisition_function(&mut self, acquisition: AcquisitionFunction)
pub fn set_acquisition_function(&mut self, acquisition: AcquisitionFunction)
Choose the acquisition function used by the Bayesian strategy.
Sourcepub fn set_tpe_config(&mut self, config: TpeConfig)
pub fn set_tpe_config(&mut self, config: TpeConfig)
Override the TPE tunables.
Sourcepub fn set_surrogate_config(&mut self, config: SurrogateConfig)
pub fn set_surrogate_config(&mut self, config: SurrogateConfig)
Override the Bayesian surrogate tunables.
Sourcepub fn set_evolution_config(&mut self, config: EvolutionConfig)
pub fn set_evolution_config(&mut self, config: EvolutionConfig)
Override the evolutionary tunables.
Sourcepub fn get_search_space(&self) -> &HyperparameterSpace<T>
pub fn get_search_space(&self) -> &HyperparameterSpace<T>
The search space this optimizer explores.
Sourcepub fn population(&self) -> &[HyperparameterConfiguration<T>]
pub fn population(&self) -> &[HyperparameterConfiguration<T>]
The evolutionary population (fittest first), which is now genuinely read by
OptimizationStrategy::Evolutionary rather than being write-only state.
Sourcepub fn surrogate_model(&self) -> Option<&SurrogateModel<T>>
pub fn surrogate_model(&self) -> Option<&SurrogateModel<T>>
The fitted surrogate’s recorded training data, or None before the
Bayesian strategy has run.
Sourcepub fn record_evaluation(&mut self, evaluation: HyperparameterEvaluation<T>)
pub fn record_evaluation(&mut self, evaluation: HyperparameterEvaluation<T>)
Record evaluation result
Sourcepub fn should_stop_early(&self) -> bool
pub fn should_stop_early(&self) -> bool
Check if optimization should stop early
Sourcepub fn get_best_configuration(&self) -> Option<&HyperparameterConfiguration<T>>
pub fn get_best_configuration(&self) -> Option<&HyperparameterConfiguration<T>>
Get the best configuration found so far
Sourcepub fn get_statistics(&self) -> OptimizationStatistics<T>
pub fn get_statistics(&self) -> OptimizationStatistics<T>
Get optimization statistics
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: Freeze,
Vec<HyperparameterEvaluation<T>>: Freeze,
Option<HyperparameterConfiguration<T>>: Freeze,
OptimizerState<T>: Freeze,
impl<T> RefUnwindSafe for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: RefUnwindSafe,
Vec<HyperparameterEvaluation<T>>: RefUnwindSafe,
Option<HyperparameterConfiguration<T>>: RefUnwindSafe,
OptimizerState<T>: RefUnwindSafe,
impl<T> Send for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: Send,
Vec<HyperparameterEvaluation<T>>: Send,
Option<HyperparameterConfiguration<T>>: Send,
OptimizerState<T>: Send,
impl<T> Sync for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: Sync,
Vec<HyperparameterEvaluation<T>>: Sync,
Option<HyperparameterConfiguration<T>>: Sync,
OptimizerState<T>: Sync,
impl<T> Unpin for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: Unpin,
Vec<HyperparameterEvaluation<T>>: Unpin,
Option<HyperparameterConfiguration<T>>: Unpin,
OptimizerState<T>: Unpin,
impl<T> UnsafeUnpin for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: UnsafeUnpin,
Vec<HyperparameterEvaluation<T>>: UnsafeUnpin,
Option<HyperparameterConfiguration<T>>: UnsafeUnpin,
OptimizerState<T>: UnsafeUnpin,
impl<T> UnwindSafe for HyperparameterOptimizer<T>where
HyperparameterSpace<T>: UnwindSafe,
Vec<HyperparameterEvaluation<T>>: UnwindSafe,
Option<HyperparameterConfiguration<T>>: UnwindSafe,
OptimizerState<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more