lava.lib.optimization.utils
lava.lib.optimization.utils.solver_tuner
digraph inheritance685c5dec64 { bgcolor=transparent; rankdir=TB; size=""; "SolverTuner" [URL="../lava-lib-optimization/lava.lib.optimization.utils.html#lava.lib.optimization.utils.solver_tuner.SolverTuner",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Utility class to optimize hyper-parameters by random search."]; }- class lava.lib.optimization.utils.solver_tuner.SolverTuner(search_space, params_names, shuffle=False, seed=0)
Bases:
object
Utility class to optimize hyper-parameters by random search.
- static generate_grid(params_domains)
- property params_names: list
- property results
Returns data on all hyper-parameters evaluations as a structured numpy array.
- property search_space: list
- property seed: int
- property shuffle: bool
- tune(solver, fitness_fn, fitness_target=None, config=SolverConfig(timeout=1000.0, target_cost=0, backend=<class 'lava.magma.core.resources.CPU'>, hyperparameters=None, probe_cost=False, probe_state=False, probe_time=False, probe_energy=False, log_level=40, folded_compilation=False))
Perform random search to optimize solver hyper-parameters based on a fitness function.
- Parameters:
solver (OptimizationSolver) – Optimization solver to use for solving the problem.
fitness_fn (ty.Callable[[SolverReport], float]) – Fitness function to evaluate a given set of hyper-parameters, taking as input a SolverReport instance (refers to its documentation for the available parameters). This is the function that is maximized by the SolverTuner.
fitness_target (float, optional) – Fitness target to reach. If this is not passed, the full grid is explored before stopping search.
config (SolverConfig, optional) – Solver configuration to be used.
- Returns:
best_hyperparams (ty.Dict) – Dictionary containing the hyper-parameters with the highest fitness.
success (bool) – Flag signaling if the fitness_target has been reached. If no fitness_target is passed, the flag is True.