Class HyperbandPruner
- Namespace
- OptunaSharp.Pruners
- Assembly
- OptunaSharp.dll
Pruner using Hyperband. Port of optuna/pruners/_hyperband.py: HyperbandPruner.
As SuccessiveHalving (SHA) requires the number of configurations n as its
hyperparameter, for a given finite budget B all the configurations have the
resources of B/n on average. Hyperband attacks this trade-off by trying different
n values for a fixed budget. Hyperband runs multiple
SuccessiveHalvingPruners ("brackets"); the number of brackets is
floor(log_eta(maxResource/minResource)) + 1.
HyperbandPruner computes the bracket ID for each trial from
study_name and the trial number (CRC-32), so specify studyName to make the
pruning algorithm reproducible.
public class HyperbandPruner : BasePruner
- Inheritance
-
HyperbandPruner
- Inherited Members
Constructors
HyperbandPruner(long, long?, int, int)
Configures resource brackets whose successive-halving competitions have separate trial histories.
public HyperbandPruner(long minResource = 1, long? maxResource = null, int reductionFactor = 3, int bootstrapCount = 0)
Parameters
minResourcelongThe minimum resource allocated to a trial (
rin the paper). See SuccessiveHalvingPruner.maxResourcelong?The maximum resource allocated to a trial, or
nullfor Optuna's"auto": estimated from the first completed trial's largest reported step (+1); no trials are pruned until determined. This value should match the maximum iteration steps.reductionFactorintReduction factor of promotable trials (
etain the paper).bootstrapCountintNumber of trials required in a rung before any trial can be promoted. Incompatible with automatic
maxResource.
Exceptions
- ValueError
Positive bootstrap is combined with automatic maximum resource.
Methods
Prune(Study, FrozenTrial)
Judge whether the trial should be pruned based on the reported values.
Note that this method is not supposed to be called by library users. Instead, Report(double, long) and ShouldPrune() provide user interfaces to implement pruning mechanism in an objective function.
public override bool Prune(Study study, FrozenTrial trial)
Parameters
studyStudyStudy object of the target study.
trialFrozenTrialFrozenTrial object of the target trial. Take a copy before modifying this object.
Returns
- bool
A boolean value representing whether the trial should be pruned.
Exceptions
- RuntimeError
The study has multiple objectives and the pruning rule requests its scalar direction.
- ValueError
Deferred bracket initialization rejects invalid resource, reduction, or bootstrap settings.
- InvalidOperationException
Initialized bracket allocation budgets are inconsistent.