liveBook · Manning

Hyperparameter tuning

As explained in Inside Deep Learning: Math, Algorithms, Models

The process of searching over user-chosen model settings to find values that improve an objective score.

Hyperparameter tuning searches user-chosen settings for values that improve a single numeric objective, such as accuracy or error. Optuna treats the search as a machine-learning task: it predicts promising settings, evaluates them, updates its model, and chooses the next trial. section 5.4.1

A practical Optuna workflow is:

  • Define an objective function that receives a trial, requests bounded values with trial.suggest functions, trains or evaluates a model, and returns a float. section 5.4.1
  • Create a study with a direction such as minimize, then call optimize with a chosen number of trials. section 5.4.1
  • Reuse nearby solutions when searching expensive linear models: warm-starting one regularization value from another can reduce training cost. section 13.2.3

Toy objective

For f(x, y) = abs((x−3)(y+2)), request x and y within [−10, 10], minimize the function for 100 trials, and inspect study.best_params. Optuna approaches x = 3 and y = −2. section 5.4.1

Figure 5.16 You supply Optuna with a function that does the three steps outlined in this diagram. Optuna uses its own algorithm to pick values for each hyperparameter, which you tell Optuna about using the trial.suggest functions; this function also informs Optuna about the minimum and maximum values you want to consider. You tell Optuna how many times to do this process, and each time it does, the black box gets better at picking new values to try.

Trace the trial loop from supplying the objective and parameter ranges to progressively better guesses. section 5.4.1

How Inside Deep Learning: Math, Algorithms, Models covers it

How deep it goes
Defines the objective-and-trial workflow but defers the technical details of Optuna’s Bayesian model.
Examples
Demonstrates Optuna on an absolute-value toy function and warm-started searches over linear-model penalties.
What it assumes
Assumes a measurable numeric objective and candidate ranges, while teaching the trial-function workflow from the beginning.
What you can do after
Apply it via Optuna by defining a scalar objective, bounding suggestions, running trials, and reading the best parameters.
How it connects
Links Bayesian optimization with model accuracy, regularization, Lasso, support vector machines, and warm starts.

Also explained in

Compare how 18 books explain hyperparameter tuning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.