SV-OpenAI-ES¶
SV_Open_ES ¶
SV_Open_ES(population_size: int, num_populations: int, solution: Solution, kernel: Callable = kernel_rbf, use_antithetic_sampling: bool = True, optimizer: GradientTransformation = optax.sgd(learning_rate=0.001), std_schedule: Callable = optax.constant_schedule(1.0), fitness_shaping_fn: Callable = centered_rank_fitness_shaping_fn, metrics_fn: Callable = metrics_fn)
Stein Variational OpenAI-ES (SV-OpenAI-ES).
Runs num_populations OpenAI-ES search distributions in parallel. The
gradient estimates of all distributions are combined with Stein variational
gradient descent: a kernel-weighted average of the gradients plus the kernel
gradient between the means, scaled by params.alpha.
Parameters:
-
population_size(int) –Number of candidate solutions sampled per search distribution in each generation. Must be even.
-
num_populations(int) –Number of search distributions run in parallel.
-
solution(Solution) –Example solution PyTree. Only its structure and leaf shapes are used: they set the number of search dimensions and how flat search vectors are unravelled into the PyTrees returned by
ask. -
kernel(Callable, default:kernel_rbf) –Function
(x, y, params) -> similaritybetween the means of two search distributions. Seeevosax.core.kernel. -
use_antithetic_sampling(bool, default:True) –If True, sample perturbations in mirrored pairs
(z, -z). -
optimizer(GradientTransformation, default:sgd(learning_rate=0.001)) –Optax optimizer applied per search distribution to the Stein variational gradient to update its mean.
-
std_schedule(Callable, default:constant_schedule(1.0)) –Function mapping the generation counter to the standard deviation of the search distribution, e.g. an Optax schedule.
-
fitness_shaping_fn(Callable, default:centered_rank_fitness_shaping_fn) –Function
(population, fitness, state, params) -> shaped_fitnessapplied per search distribution to the raw fitness intellbefore the algorithm update. Seeevosax.core.fitness_shaping. -
metrics_fn(Callable, default:metrics_fn) –Function
(key, population, fitness, state, params) -> metricsevaluated per search distribution intell; its output is returned alongside the new state.
References
default_params
property
¶
Default hyperparameters of the algorithm.
Returns a Params dataclass. Use params.replace(...) to override
individual hyperparameters before passing it to init, ask and tell.
init ¶
Initialize the algorithm state from one initial mean per distribution.
Parameters:
-
key(Array) –PRNG key.
-
means(Solution) –Initial means, a PyTree with the structure of
solutionand a leading axis of sizenum_populationson every leaf. -
params(Params) –Algorithm hyperparameters, e.g.
default_params.
Returns:
-
State–The initial algorithm state.
ask ¶
Ask for a population of candidate solutions to evaluate.
Parameters:
-
key(Array) –PRNG key.
-
state(State) –Current algorithm state.
-
params(Params) –Algorithm hyperparameters.
Returns:
-
tuple[Population, State]–A tuple
(population, state).populationis a PyTree with the structure ofsolutionand a leading axis of sizenum_populations * population_size.
tell ¶
tell(key: Array, population: Population, fitness: Fitness, state: State, params: Params) -> tuple[State, Metrics]
Update the algorithm state with the fitness of a population.
Parameters:
-
key(Array) –PRNG key.
-
population(Population) –Population returned by
ask. -
fitness(Fitness) –Fitness of each population member, shape
(num_populations * population_size,). Lower is better. -
state(State) –Algorithm state returned by
ask. -
params(Params) –Algorithm hyperparameters.
Returns:
-
tuple[State, Metrics]–A tuple
(state, metrics)with the updated state and the output ofmetrics_fnfor each search distribution.
get_mean ¶
Return the means of all search distributions as a PyTree.
Every leaf has a leading axis of size num_populations.