Tuning Deep Networks on a Budget
Which hyperparameters matter, in what order, and how to search them.
A deep network has dozens of knobs, and a full training run can take days, so you never get to try them all. Tuning well means knowing which few knobs matter, how they interact, how to search them so that every run teaches you something, and how the cheap shortcuts (short runs, small models) can quietly mislead you.
What you’ll learn
- Rank hyperparameters by importance (learning rate first) and explain their main interactions: learning rate with batch size, with weight decay in AdamW, and with width.
- Derive the distribution of the best of random trials, compute how many trials reach the top fraction of a search space, and explain why random and quasi-random search beat grids when few hyperparameters matter.
- Explain multi-fidelity methods and population-based training, and the short-horizon bias that makes short runs favor learning rates that are too small.
- Use the scientific/nuisance distinction of the tuning playbook, and recognize how unequal tuning budgets have produced spurious improvements.
Which knobs matter
Not all hyperparameters are equal. The learning rate comes first: "often the single most important hyper-parameter" (Bengio, 2012), it can change the final loss by orders of magnitude, and nearly every other knob shifts its best value. A rough order of importance, with the scale to search on:
| Hyperparameter | Search scale | Interacts most with |
|---|---|---|
| learning rate (peak) | logarithmic, factors of 2–3 apart | everything: batch size, weight decay, warmup, width, depth |
| schedule: decay shape and length, warmup | a few discrete choices; warmup as a fraction of the run | learning rate, training length |
| weight decay | logarithmic | learning rate (in AdamW the per-step decay is their product) |
| batch size | powers of 2, chosen for throughput | learning rate, momentum, regularization |
| model size: width and depth | powers of 2 | learning rate (unless the parameterization keeps it fixed, as μP does) |
| regularization: dropout, label smoothing, augmentation strength | linear or a few levels | model size, data size |
| Adam's | on a log scale | learning rate; matter mostly for large or unstable runs |
Interactions. Hyperparameters cannot be tuned one at a time in a fixed order without care, because their optima move together:
- Learning rate and batch size. For SGD, multiplying the batch by calls for roughly times the learning rate, with warmup, up to a limit (the linear scaling rule, Goyal et al., 2017); for Adam, roughly (Malladi, Lyu, Panigrahi & Arora, 2022). Gradient Noise, Batch Size & Scaling Rules derives the first from the SDE view of SGD and explains the second.
- Learning rate and weight decay. PyTorch's
AdamWmultiplies the weights by each step, where is the learning rate and theweight_decay, so doubling doubles the decay as well. Decoupling weight decay from the gradient update made the two easier to tune separately than with an penalty inside Adam (Loshchilov & Hutter, 2019), but in this form their product still sets the decay's timescale (What Weight Decay Really Does). - Learning rate and width. Under the standard parameterization, the best learning rate drifts as models get wider, which is why tuning a small model and copying its rate to a big one usually fails, unless the model is parameterized so that the rate transfers (μP & Hyperparameter Transfer).
Searching: grids, random draws and the best of n
A grid with values for each of hyperparameters costs runs but tries only distinct values of any single hyperparameter. If only one or two of them matter, most of those runs are repeats along axes that make no difference. Bergstra & Bengio (2012) found exactly this low effective dimensionality for neural networks: on each dataset only a few hyperparameters mattered, and which ones varied between datasets. Random search with the same budget tries distinct values of every hyperparameter, and its success rate does not depend on at all:
Let the validation scores of configurations drawn independently from the search distribution be i.i.d. with CDF , higher being better. The best of them is at most only if every one is:
Call the top fraction of the search distribution "good": scores above the quantile . The chance that at least one of trials lands there depends on neither the number of hyperparameters nor the shape of :
So 60 random trials reach the top 5% of the search space with 95% probability. For a target confidence :
The expected best score after trials follows from , and can be estimated from the empirical distribution of trials already run. Plotted against , it shows how much of a method's advantage comes from search effort (Dodge, Gururangan, Card, Schwartz & Smith, 2019). The guarantee is only relative to the search space: if the space is badly chosen, its top 5% may still be poor.
How many independent random trials do you need so that, with probability at least 95%, the best one lies in the top 1% of the search distribution?
Show the answer
299 trials
, so 299 trials, five times as many as for the top 5%. Each tenfold refinement of the target costs about tenfold more trials, which is why the search space and the order of tuning matter more than raw trial counts.
Better than independent draws. Quasi-random (low-discrepancy) sequences cover the space more evenly than independent draws while keeping random search's advantages; the tuning playbook recommends them for the exploration phase (Godbole et al., 2023). Bayesian optimization fits a probabilistic model of the score as a function of the hyperparameters and picks each next trial by an acquisition function such as expected improvement (Snoek, Larochelle & Adams, 2012). The playbook reserves it for the end, to exploit a space that exploration has made well understood. When many trials run in parallel, quasi-random search is hard to beat, since an adaptive method has few finished trials to learn from. The Machine Learning course's Hyperparameter Optimization derives expected improvement and the budgets of the multi-fidelity methods below.
Search on the right scale: draw learning rates and weight decays log-uniformly (for example with uniform on ), and if the best trial lands on an edge of the range, extend the range and search again.
Cheap proxies and their biases
Most of a search's budget is spent on configurations that turn out bad, so it pays to stop them early. Successive halving starts many configurations with a small budget, keeps the best fraction, multiplies their budget by , and repeats (Jamieson & Talwalkar, 2016). Hyperband runs several such brackets with different trade-offs between the number of configurations and the starting budget (Li, Jamieson, DeSalvo, Rostamizadeh & Talwalkar, 2018); ASHA makes it asynchronous for large clusters (Li et al., 2020), and BOHB replaces the random proposals with a model (Falkner, Klein & Hutter, 2018).
All of these assume that rankings after a short run predict rankings after a long one. For the learning rate and the schedule, deep learning violates that assumption in a systematic direction.
Population-based training (Jaderberg et al., 2017) turns tuning into part of training. A population of models trains in parallel; periodically, poorly performing members copy the weights of better ones (exploit) and perturb their hyperparameters (explore). The result is a hyperparameter schedule rather than a fixed setting, found within roughly the cost of the population's training runs.
Transfer from small to large. The cheapest proxy is a smaller model. Under the standard parameterization the best learning rate shifts with width, so small-model tuning misleads; under μP it stays put, so a learning rate tuned on a narrow proxy can be reused at full width (μP & Hyperparameter Transfer). How sharply the final loss depends on the learning rate is itself a property worth measuring: Wortsman et al. (2024) used this learning-rate sensitivity to evaluate interventions such as QK layer normalization, the z-loss, warmup, weight decay and μP; combining them, they trained small transformers that reached similar losses across orders of magnitude of learning rate.
Budgets decide comparisons
Tuning effort is a hidden variable in almost every published comparison, and when it was equalized, several celebrated improvements shrank or vanished:
- Language models. With large-scale automatic black-box tuning of every model, standard LSTMs, properly regularized, outperformed more recent recurrent architectures on Penn Treebank and WikiText-2 (Melis, Dyer & Blunsom, 2018).
- GANs. With enough hyperparameter optimization and random restarts, most GAN variants reached similar scores, and none consistently beat the original non-saturating GAN (Lucic, Kurach, Michalski, Gelly & Bousquet, 2018).
- Metric learning. After fixing flaws in experimental methodology, a decade of reported improvements in deep metric learning turned out to be marginal at best (Musgrave, Belongie & Lim, 2020).
- Reporting. Plotting the expected best validation score against the number of trials showed that several published conclusions would have reversed with a different budget (Dodge et al., 2019).
A new architecture, tuned over 200 trials, beats a baseline that was run once at its published default settings by one point of accuracy. What does this show?
- That the new architecture is better, since one point is a large margin
- That the baseline's defaults were wrong
- Little: the comparison confounds the architecture with 200 times more tuning, and the baseline must get the same budget and search procedure
- That 200 trials are enough to tune any model
Show the answer
C. Little: the comparison confounds the architecture with 200 times more tuning, and the baseline must get the same budget and search procedure
The best of 200 trials is an optimistic draw from the new method's distribution, while the baseline gets a single draw. Equal budgets, equal search spaces chosen in advance, and repeated runs are the minimum for the comparison to mean anything; in the studies above, such controls erased gains of this size.
Hygiene. Choose the search space before seeing results and report it; tune on a validation split and touch the test set once; give every method the same budget and search procedure; report the number of trials alongside the score; and re-run the final configuration with several seeds, since the best trial of a search is partly selected for luck (Benchmarking Deep Learning Fairly).
Key takeaways
- Tune the learning rate first, on a logarithmic scale, then the schedule, weight decay, model size and regularization; treat the batch size as a throughput choice and retune the rate when it changes. The optimal values move together (learning rate with batch size, with AdamW's weight decay, with width).
- The best of independent trials lands in the top fraction of the search distribution with probability , whatever the number of hyperparameters: 60 trials for the top 5%, 299 for the top 1%, at 95%. Random and quasi-random search beat grids because few hyperparameters matter.
- Cheap proxies are biased: short runs favor rates that are too small and schedules that decay early (short-horizon bias), and small models mislead unless the parameterization makes hyperparameters transfer.
- Tuning budgets decide comparisons: with equal effort, reported gains for new LSTM variants, GANs and metric-learning losses shrank or vanished. Treat nuisance hyperparameters as nuisances and report the budget.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
You can afford 64 runs to tune 3 hyperparameters, of which only the learning rate matters much. How many distinct learning rates does a grid try, compared with 64 random draws?
- 64 for the grid, 4 for random search
- 4 for the grid, 64 for random search
- 64 for both
- 16 for the grid, 4 for random search
Show the answer
B. 4 for the grid, 64 for random search
The grid repeats each of its 4 learning rates 16 times, varying only the two unimportant hyperparameters. Random draws give a new learning rate in every run, so all 64 runs inform the one decision that matters.
To save time you rank learning rates by their validation loss after the first 5% of a long run whose schedule decays only later. Which way are you likely to be biased?
- Toward rates that are too small: large rates pay a noise penalty early that the later decay removes
- Toward rates that are too large, because they make faster initial progress
- There is no bias, since rankings stabilize after the first few hundred steps
- Toward rates near the stability limit, because they are the noisiest
Show the answer
A. Toward rates that are too small: large rates pay a noise penalty early that the later decay removes
Before decay, the loss sits on a noise floor that grows with the rate, so smaller rates often look better early and worse at the end. This is the short-horizon bias that Wu et al. (2018) quantified for learning-rate meta-optimization.
With PyTorch's AdamW, you double the learning rate and keep weight_decay fixed. What happens to the weight decay applied per step?
- Nothing: AdamW's decay is independent of the learning rate
- It halves, because the decay is divided by the learning rate
- It is applied only every other step
- It doubles, because each step multiplies the weights by
Show the answer
D. It doubles, because each step multiplies the weights by
PyTorch's AdamW applies with the learning rate, so the two multiply. When you retune one, check the other, or reason in terms of the product .
You want to know whether GELU beats ReLU in your model. In the tuning playbook's terms, how should you treat the learning rate?
- As a scientific hyperparameter: compare GELU and ReLU at several learning rates and report all of them
- As a nuisance hyperparameter: tune it separately for GELU and for ReLU, with the same budget, and compare the best of each
- As a fixed hyperparameter: use the value tuned for ReLU for both
- It does not matter, since activations do not interact with the learning rate
Show the answer
B. As a nuisance hyperparameter: tune it separately for GELU and for ReLU, with the same budget, and compare the best of each
The activation is the scientific hyperparameter. The learning rate is a nuisance: its best value can differ between the two activations, so each must get its own equally thorough search before they are compared.
Further reading
- J. Bergstra & Y. Bengio, "Random search for hyper-parameter optimization," JMLR 13 (2012).
- V. Godbole, G. E. Dahl, J. Gilmer, C. J. Shallue & Z. Nado, Deep Learning Tuning Playbook, version 1 (2023), github.com/google-research/tuning_playbook.
- L. Li, K. Jamieson, G. DeSalvo, A. Rostamizadeh & A. Talwalkar, "Hyperband: A novel bandit-based approach to hyperparameter optimization," JMLR 18 (2018).
- Y. Wu, M. Ren, R. Liao & R. Grosse, "Understanding short-horizon bias in stochastic meta-optimization," ICLR (2018).
- G. Melis, C. Dyer & P. Blunsom, "On the state of the art of evaluation in neural language models," ICLR (2018).
- J. Dodge, S. Gururangan, D. Card, R. Schwartz & N. A. Smith, "Show your work: Improved reporting of experimental results," EMNLP (2019).