Class SnesSampler
- Namespace
- OptunaSharp.Samplers
- Assembly
- OptunaSharp.dll
A sampler driving Separable Natural Evolution Strategies (Wierstra et al. 2014): a diagonal Gaussian
with a per-coordinate mean and scale, adapted by natural-gradient steps. Because σ is adapted per
coordinate, SNES converges to high precision without the fixed-σ floor of OpenAiEsSampler,
while costing only O(d) per sample — the practical NES for higher-dimensional continuous
hyperparameter spaces where full-covariance CmaEsSampler becomes expensive. The price
is an assumption of (approximate) coordinate independence.
Unsupported parameters. Categorical parameters and single-valued distributions are sampled by the independent sampler, as in CmaEsSampler. Dynamic search spaces fall back to independent sampling with a warning.
public sealed class SnesSampler : EvolutionStrategySampler
- Inheritance
-
SnesSampler
- Inherited Members
Examples
var study = Optuna.CreateStudy(sampler: new SnesSampler(seed: 42));
study.Optimize(t =>
{
double s = 0;
for (int i = 0; i < 10; i++) { double x = t.SuggestFloat($"x{i}", -5, 5); s += x * x; }
return s;
}, nTrials: 500);
Constructors
SnesSampler(int, BaseSampler?, bool, int?, double, double, double?, int?)
Configures SNES proposals and its independent startup and unsupported-parameter fallback.
public SnesSampler(int nStartupTrials = 1, BaseSampler? independentSampler = null, bool warnIndependentSampling = true, int? seed = null, double sigma = 0.3, double etaMu = 1, double? etaSigma = null, int? popsize = null)
Parameters
nStartupTrialsintIndependent sampling is used until this many trials complete.
independentSamplerBaseSamplerSampler for parameters outside the relative search space (default RandomSampler).
warnIndependentSamplingboolEmit a warning when a parameter is sampled independently.
seedint?Random seed for SNES.
sigmadoubleInitial per-coordinate scale σ in the transformed
[0,1]space (default 0.3).etaMudoubleMean learning rate η_μ (Table 1 default 1.0).
etaSigmadouble?Scale learning rate η_σ;
nulluses the Table 1 default(3 + ln d)/(5√d).popsizeint?Population size λ per generation;
nulluses the Table 1 default4 + ⌊3 ln d⌋.
Exceptions
- ArgumentException
The initial scale σ is not strictly positive.
Properties
AttrPrefix
The system-attr key prefix distinguishing this sampler's stored state (e.g. "openaies:").
protected override string AttrPrefix { get; }
Property Value
SamplerLogger
The logger namespace for this sampler (e.g. "optuna.samplers.openai_es").
protected override Logger SamplerLogger { get; }