メインコンテンツまでスキップ
バージョン: v2506

tuner

GeneralTuner Objects

class GeneralTuner()

Base class for tuners.

__init__

def __init__(output_dir: str = "outputs",
study_name: str = None,
db_path: Optional[str] = None,
sampler: Optional[BaseSampler] = None,
maximize: bool = False) -> None

Initialize the GeneralTuner.

Arguments:

  • output_dir str - The directory to store the study results. Defaults to "outputs".
  • study_name str - The name of the study. Defaults to None.
  • db_path Optional[str] - The path to the database file. Defaults to None.
  • sampler Optional[BaseSampler] - The sampler to use. Defaults to None.
  • maximize bool - Whether to maximize the objective function. Defaults to False.

optimize

def optimize(
objective: Callable[..., Optional[float]],
n_trials: int,
default_params: Optional[Dict[str, Any]] = None
) -> Tuple[float, Dict[str, Any]]

Optimize the given objective function using Optuna.

Arguments:

  • objective Callable[..., Optional[float]] - The objective function to optimize.
  • n_trials int - The number of trials to run.
  • default_params Optional[Dict[str, Any]] - Default parameters to use for the first optimization.

Returns:

Tuple[float, Dict[str, Any]]: The best value and parameters found during optimization.

analyze

def analyze(plot_contour: bool = True,
plot_importances: bool = True,
plot_history: bool = True,
plot_timeline: bool = True) -> None

Analyze the optimization results.

Arguments:

  • plot_contour bool - Whether to plot the contour plot. Defaults to True.
  • plot_importances bool - Whether to plot the parameter importances. Defaults to True.
  • plot_history bool - Whether to plot the optimization history. Defaults to True.
  • plot_timeline bool - Whether to plot the timeline. Defaults to True.

FunctionRuntimeTuner Objects

class FunctionRuntimeTuner(GeneralTuner)

A tuner for runtime optimization.

__init__

def __init__(output_dir: str = "outputs",
study_name: Optional[str] = None,
db_path: Optional[str] = None,
sampler: Optional[BaseSampler] = None,
maximize: bool = False) -> None

Initialize the FunctionRuntimeTuner.

Arguments:

  • output_dir str - The directory to store the study results. Defaults to "outputs".
  • study_name str - The name of the study. Defaults to None.
  • db_path Optional[str] - The path to the database file. Defaults to None.
  • sampler Optional[BaseSampler] - The sampler to use. Defaults to None.
  • maximize bool - Whether to maximize the objective function. Defaults to False.

optimize

def optimize(
func: Callable[..., Any],
n_trials: int,
default_params: Optional[Dict[str, Any]] = None
) -> Tuple[float, Dict[str, Any]]

Optimize the given objective function using Optuna.

Arguments:

  • func Callable[..., Any] - The objective function to optimize.
  • n_trials int - The number of trials to run.
  • default_params Optional[Dict[str, Any]] - Default parameters to use for the optimization.

Returns:

Tuple[float, Dict[str, Any]]: The best value and parameters found during optimization.

CommandRuntimeTuner Objects

class CommandRuntimeTuner(FunctionRuntimeTuner)

A tuner for executing runtime commands.

__init__

def __init__(output_dir: str = "outputs",
study_name: Optional[str] = None,
db_path: Optional[str] = None,
sampler: Optional[BaseSampler] = None,
maximize: bool = False) -> None

Initialize the CommandRuntimeTuner.

Arguments:

  • output_dir str - The directory to store the study results. Defaults to "outputs".
  • study_name str - The name of the study. Defaults to None.
  • db_path Optional[str] - The path to the database file. Defaults to None.
  • sampler Optional[BaseSampler] - The sampler to use. Defaults to None.
  • maximize bool - Whether to maximize the objective function. Defaults to False.

optimize

def optimize(command_generator: Callable[..., str],
n_trials: int,
default_params: Optional[Dict[str, Any]] = None,
log: bool = False) -> Tuple[float, Dict[str, Any]]

Optimize the given objective function using Optuna.

Arguments:

  • command_generator Callable[..., str] - A function that generates the command to execute.
  • n_trials int - The number of trials to run.
  • default_params Optional[Dict[str, Any]] - Default parameters to use for the optimization.
  • log bool - Whether to log the command execution. Defaults to False.

Returns:

Tuple[float, Dict[str, Any]]: The best value and parameters found during optimization.

CommandOutputTuner Objects

class CommandOutputTuner(GeneralTuner)

A tuner for executing commands and extracting values.

__init__

def __init__(output_dir: str = "outputs",
study_name: Optional[str] = None,
db_path: Optional[str] = None,
sampler: Optional[BaseSampler] = None,
maximize: bool = False) -> None

Initialize the CommandOutputTuner.

Arguments:

  • output_dir str - The directory to store the study results. Defaults to "outputs".
  • study_name str - The name of the study. Defaults to None.
  • db_path Optional[str] - The path to the database file. Defaults to None.
  • sampler Optional[BaseSampler] - The sampler to use. Defaults to None.
  • maximize bool - Whether to maximize the objective function. Defaults to False.

optimize

def optimize(command_generator: Callable[..., str],
value_extractor: Callable[[str], Optional[float]],
n_trials: int,
default_params: Optional[Dict[str, Any]] = None,
log: bool = True) -> Tuple[float, Dict[str, Any]]

Optimize the given objective function using Optuna.

Arguments:

  • command_generator Callable[..., str] - A function that generates the command to execute.
  • value_extractor Callable[[str], Optional[float]] - A function that extracts the value from the log file.
  • n_trials int - The number of trials to run.
  • default_params Optional[Dict[str, Any]] - Default parameters to use for the optimization.
  • log bool - Whether to log the command execution. Defaults to True.
  • log_all_rank bool - Whether to log the command execution on all ranks. Defaults to False.

Returns:

Tuple[float, Dict[str, Any]]: The best value and parameters found during optimization.