Skip to content
AI360XpertBeta
Core ML

Visual explainer

Hyperparameter Tuning

Compare grid, random and adaptive search on a checked loss surface, allocate training resources, and keep selection separate from final evaluation.

Hyperparameter tuning chooses settings outside the model's weight-fitting loop by comparing validation results. Search quality depends on the candidate range, scoring rule, split design and compute budget; the winning validation score needs a separate final evaluation.

Which setting changes the result?

The same loss scale reveals a stronger response to learning rate than batch size.
The same loss scale reveals a stronger response to learning rate than batch size.

Both vertical axes show loss, where lower is better. Both horizontal axes run from normalized coordinate 0 to 1: uu represents log learning rate from 10−410^{-4} to 10−110^{-1}, and vv represents batch size 16 to 256. Treating batch size as continuous is an idealization for this sensitivity picture; real batch sizes are integers.

This is a synthetic analytic surface, not a training benchmark:

L(u,v)=0.20+0.40(u−0.50)2+0.02v.L(u,v)=0.20+0.40(u-0.50)^2+0.02v.

The left slice fixes v=0.5v=0.5: losses at u=0,0.25,0.5,0.75,1u=0,0.25,0.5,0.75,1 are 0.31,0.235,0.21,0.235,0.310.31,0.235,0.21,0.235,0.31. Its range is 0.10. The right slice fixes u=0.5u=0.5, so loss rises from 0.20 to 0.22: range 0.02. The identical vertical scales make this comparison honest. Which settings matter can change with the dataset, model and range.

What does a grid repeat?

Sixteen grid combinations project onto four distinct learning rates.
Sixteen grid combinations project onto four distinct learning rates.

Each dot is a candidate configuration, with uu horizontal and vv vertical. Four values per axis form 4×4=164\times4=16 combinations. The projection onto the horizontal axis contains only four learning rates. These are not sixteen identical trainings: changing batch size can change the outcome, and interactions can make a grid useful. On a surface dominated by one direction, repeated values leave less coverage of that direction. A CV search also fits each configuration once per fold, so 16 candidates with five folds require 80 fits before a final refit.

What does random search cover?

This sixteen-trial random sample projects onto sixteen distinct learning rates.
This sixteen-trial random sample projects onto sixteen distinct learning rates.

The axes and domain match the grid. This illustrative set contains 16 distinct horizontal coordinates, so the bottom projection has 16 ticks. Continuous random sampling has probability zero of an exact repeat under ideal real-valued arithmetic; finite/discrete choices and computer precision change that statement. More distinct values do not guarantee a lower best loss. The sampling distribution and chosen bounds determine which regions receive attention. This coverage argument follows the motivation in Bergstra and Bengio's random-search paper.

Can earlier results guide a later trial?

An adaptive search uses observed losses before proposing the next trial.
An adaptive search uses observed losses before proposing the next trial.

The four filled dots are observations of the same v=0.5v=0.5 slice at u=0,0.25,0.75,1u=0,0.25,0.75,1, giving losses 0.31,0.235,0.235,0.31. The empty diamond marks a proposed u=0.5u=0.5; its location on the baseline encodes the proposed setting, not an observed loss. This trial has not run yet. This separate plot uses a wider vertical loss range than the sensitivity panels; compare its labeled losses, not pixel heights across figures.

An adaptive method uses the history to choose what to evaluate next. Bayesian optimization can combine a surrogate's predicted quality and uncertainty through an acquisition rule; this drawing computes neither a posterior nor an acquisition curve. Exploring uncertain regions can prevent repeatedly exploiting a misleading local winner. No optimizer can infer unseen performance without assumptions.

How can partial training save resources?

Continuing only survivors spends twenty candidate-epochs instead of sixty-four.
Continuing only survivors spends twenty candidate-epochs instead of sixty-four.

Here horizontal length is the cumulative number of training epochs given to each candidate. Start eight candidates for one epoch, retain four until epoch 2, two until epoch 4, and one until epoch 8. The stopped tracks show four candidates ending at 1, two at 2, one at 4 and one at 8.

If surviving fits continue from checkpoints, additional work is 8(1)+4(2−1)+2(4−2)+1(8−4)=208(1)+4(2-1)+2(4-2)+1(8-4)=20 candidate-epochs. Training all eight to epoch 8 costs 64. If each rung restarts fitting, the budget is 8(1)+4(2)+2(4)+1(8)=328(1)+4(2)+2(4)+1(8)=32 instead. These are different execution assumptions. Real cost also includes validation and overhead. The scikit-learn search guide explains successive halving and its resource choices; this continuation fixture is not a promise about its implementation.

Which trials depend on earlier results?

Independent trials can run together while a sequential proposal waits for results.
Independent trials can run together while a sequential proposal waits for results.

Independent candidates can start together when workers are available. In the right-hand schematic, proposal 2 uses result 1, proposal 3 uses result 2, and the dashed fourth job is still being proposed. Positions show dependencies, not measured elapsed time. Adaptive batch methods also exist; expensive training alone does not mandate a particular optimizer. Compare search overhead, available parallelism and the value of learning from each result.

Why choose a logarithmic range?

Equal distances on a log scale represent equal multiplicative learning-rate changes.
Equal distances on a log scale represent equal multiplicative learning-rate changes.

The same four learning rates appear on two rulers with identical endpoints. On a linear ruler, 0.00010.0001 and 0.0010.001 sit very close together; that bunching is deliberate, not a zoom. On the log ruler, 10−4,10−3,10−2,10−110^{-4},10^{-3},10^{-2},10^{-1} are equally spaced because each step multiplies by 10. A uniform draw in log space gives equal probability to equal multiplicative intervals. This can suit positive scale parameters spanning several orders of magnitude, but the bounds remain a substantive assumption. A good setting outside the chosen range is unreachable.

What model is finally fitted?

The selected settings are refitted on all development data before final evaluation.
The selected settings are refitted on all development data before final evaluation.

The three adjacent partitions depict the development data used during selection. Their merge feeds a fresh fit with the chosen settings, producing one final model. Partition widths are schematic membership groups, not prescribed percentages. During CV, every fold has its own fitted model and preprocessing; after selecting settings, refitting uses all permitted development rows. The test data remains outside this fit.

What does the test set decide?

A test set evaluates the chosen model without feeding the search loop.
A test set evaluates the chosen model without feeding the search loop.

The left loop compares configurations using validation scores. The right branch evaluates the already-chosen, refitted model. There is no return arrow from its test result to the search. Repeatedly changing settings after inspecting that result makes the test part of selection. A separate holdout or an outer loop in nested cross-validation estimates the performance of the selection procedure; neither guarantees future deployment performance. The nested-CV example demonstrates why selection and evaluation need different roles. No fixed optimistic score gap follows from tuning alone.

Where does early culling fail?

Early culling can discard a candidate that would win with more training.
Early culling can discard a candidate that would win with more training.

This final picture changes to a stated synthetic two-candidate training fixture, with its own epoch and loss axes; pixel scales differ from the resource tracks. At epochs 1,2,4,8, A's losses are 0.40,0.35,0.32,0.30; B's are 0.60,0.45,0.25,0.20. Stopping B at epoch 1 looks reasonable from the observed ranking, yet B would win at epoch 8. The cross marks the actual stop; B's dashed tail is the counterfactual result if training had continued, not observed evidence available at the stop.

Early resource allocation assumes short-budget scores are informative about the desired full-budget ranking. Crossing learning curves violate that assumption. Delay elimination, allocate a larger minimum budget, or fully train a small check set when late improvement is plausible. Resource savings buy less information about discarded candidates.

The Quick Version

  • A grid enumerates combinations; repeated coordinates can still reveal interactions.
  • Random coverage depends on its distribution and candidate domain.
  • Adaptive proposals use history and introduce result dependencies.
  • Continuation and restarting require different compute accounting.
  • Refit selected settings on development data, then evaluate separately.
  • Early ranking can discard a late winner.