Open source

Optuna

Quick explainer2 min readIntermediate

Optuna is an open-source Python framework that automatically searches for good hyperparameters, the settings you choose before training a machine learning model.

In plain words

Settings such as the learning rate or the number of layers can make or break a model, and trying them by hand is slow. With Optuna you write an objective function that trains a model and returns a score. Inside it, a trial object suggests values to try. A study runs many trials, uses smart sampling to pick promising values, and can stop unpromising trials early. Because the search space is ordinary Python, it can include if statements and loops.

A quick example

Optuna's own example tunes a PyTorch network. The objective function asks the trial for a number of layers and a number of hidden units per layer, trains the network, and returns its accuracy. The study repeats this for many trials and reports the best settings it found.

Where you'll meet it

  • Tuning deep learning and classic machine learning models.
  • Comparing different model types within one search.

Related

Sources

  1. DocsOptuna: A hyperparameter optimization framework, Optuna documentation · read 29 Sept 2026
  2. DocsOptuna, Optuna · read 29 Sept 2026

Checked by WhatIsAI against the sources above · 29 Sept 2026. Spotted an error? Report it.