liveBook · Manning

Optuna

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

A hyperparameter-optimization library that searches parameter spaces by running trials and using a model to guide new suggestions.

Optuna searches for useful hyperparameter values by evaluating trials and using earlier results to guide later suggestions. It suits goals that can be expressed as a single numeric score, such as accuracy or error. section 5.4 section 5.4.1

Define an objective function that receives a trial, requests candidate values within specified ranges, and returns a score. Create a study with a minimize or maximize direction, then run the objective for a chosen number of trials. Optuna models the relationship between hyperparameters and score, using its predictions to suggest later trials; the technical details of that model are left aside. section 5.4.1 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.

The diagram traces the loop from defining an objective and search ranges to evaluating trials and improving later suggestions. section 5.4.1

A two-variable search

For f(x, y) = |(x − 3)(y + 2)|, request trial values for x and y from ranges of −10 to 10, then return the function value. A minimizing study can approach the minimum near x = 3 and y = −2. section 5.4.1

In neural-network training, candidate settings can include learning rate, momentum, layer count, and hidden-layer width. Tuning can be expensive: it may require training many models, so the available computational budget matters. section 5.4

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

How deep it goes
Explains the objective-and-trial workflow and sequential Bayesian suggestions, while deferring the model’s technical details.
Examples
Uses a two-variable toy function and proposes tuning fully connected or convolutional networks on FashionMNIST.
What it assumes
Requires a scalar objective and defined ranges for candidate values; demonstrates these requirements with a toy function.
What you can do after
Apply Optuna by defining a trial-based objective, choosing a study direction, and running a specified number of trials.
How it connects
Connects hyperparameter optimization with grid search, Bayesian optimization, and neural-network training.

Also explained in

Compare how 3 books explain Optuna →

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.