The search is over a space you cannot differentiate
Parameters are learned from the data. Hyperparameters are set before training and cannot be learned by the same gradient, because the loss is not differentiable with respect to them.
- : one setting of every hyperparameter.
- : the space of settings being searched.
- : the validation loss after training with that setting.
Every evaluation of that objective costs a full training run, which is what makes this a search problem rather than an optimisation.
Why random search beats grid search
A grid over hyperparameters with values each has points, so five values across six hyperparameters is 15,625 training runs.
Random search instead draws settings at random, and the probability of missing the best fraction of the space falls geometrically.
With and trials, the chance of landing in the top 5 percent is about 95 percent, whatever the number of hyperparameters is.
The deeper reason is that most hyperparameters barely matter. A grid spends runs re-testing the same value of the one that does, and random search never repeats a value.
The order to search in
Learning rate matters more than everything else combined, and it is searched on a logarithmic scale because 0.001 and 0.003 differ more than 0.1 and 0.103.
Batch size, weight decay and dropout come next. Architecture details usually come last, and most defaults are defaults because they are fine.
One tuning run, in order
- Fix the search space, with log scales on anything spanning orders of magnitude.
- Draw a setting at random, or from the surrogate model if using Bayesian search.
- Train and score it on the validation folds.
- Record the setting and its score, and stop early if the run is clearly losing.
- Repeat for the budget, then retrain the winner on train and validation together.
What Bayesian optimisation adds, and when it does not
It fits a cheap model of the score surface from the trials so far, then picks the next setting by expected improvement.
That spends trials where the surface looks promising or where it has never been measured.
It wins when each training run is expensive and the budget is small.
It loses when runs are cheap enough to parallelise, because random search parallelises perfectly and Bayesian search is sequential by design.
Successive halving takes the third route: start many settings, train them briefly, and keep only the best fraction each round, which is what Hyperband automates.