TrialPruner<T>
Models & Types · AiDotNet.HyperparameterOptimization
Provides trial pruning functionality for hyperparameter optimization.
How It Works
For Beginners: Trial pruning allows early termination of unpromising trials:
- During training, periodically report intermediate results
- Pruner compares against historical data from other trials
- If the current trial is clearly worse, it gets pruned (stopped early)
- This saves computational resources for more promising trials
Key concepts:
- Intermediate Value: A performance metric reported during training
- Step: The training progress when the value was reported
- Pruning: Terminating a trial that’s unlikely to improve
Trial pruning is especially useful with Bayesian optimization and Hyperband where many configurations are evaluated.
Constructors
| Constructor | Summary |
|---|---|
TrialPruner(bool maximize, PruningStrategy strategy, double percentile, int warmupSteps, int checkInterval) |
Initializes a new instance of the TrialPruner class. |
Methods
| Method | Summary |
|---|---|
TrialPrunerStatistics GetStatistics() |
Gets statistics about pruning decisions. |
bool CheckThreshold(double value, double threshold) |
Checks if a trial should be pruned based on a threshold. |
bool ReportAndCheckPrune(HyperparameterTrial<T> trial, int step, T value) |
Reports an intermediate value and checks if the trial should be pruned. |
bool ReportAndCheckPrune(string trialId, int step, double value) |
Reports an intermediate value and checks if the trial should be pruned. |
void MarkComplete(string trialId) |
Marks a trial as complete (called when trial finishes without pruning). |
void Reset() |
Resets the pruner state. |