optuna.trial.FixedTrial

class optuna.trial.FixedTrial(params, number=0)[源代码]

A trial class which suggests a fixed value for each parameter.

This object has the same methods as Trial, and it suggests pre-defined parameter values. The parameter values can be determined at the construction of the FixedTrial object. In contrast to Trial, FixedTrial does not depend on Study, and it is useful for deploying optimization results.

示例

Evaluate an objective function with parameter values given by a user.

import optuna


def objective(trial):
    x = trial.suggest_uniform("x", -100, 100)
    y = trial.suggest_categorical("y", [-1, 0, 1])
    return x ** 2 + y


assert objective(optuna.trial.FixedTrial({"x": 1, "y": 0})) == 1

备注

Please refer to Trial for details of methods and properties.

参数
  • params (Dict[str, Any]) – A dictionary containing all parameters.

  • number (int) – A trial number. Defaults to 0.

返回类型

None

Methods

report(value, step)

set_system_attr(key, value)

set_user_attr(key, value)

should_prune()

suggest_categorical(name, choices)

suggest_discrete_uniform(name, low, high, q)

suggest_float(name, low, high, *[, step, log])

suggest_int(name, low, high[, step, log])

suggest_loguniform(name, low, high)

suggest_uniform(name, low, high)

Attributes

datetime_start

distributions

number

params

system_attrs

user_attrs