hyper_opt

Base class for all hyperparameter optimizers.

class HyperOpt(params: Parameters, data=None, use_pkl_checkpoints=False)[source]

Bases: ABC

Base class for hyperparameter optimizer.

Parameters:
  • params (mala.common.parametes.Parameters) – Parameters used to create this hyperparameter optimizer.

  • data (mala.datahandling.data_handler.DataHandler) – DataHandler holding the data for the hyperparameter optimization.

  • use_pkl_checkpoints (bool) – If true, .pkl checkpoints will be created.

params

MALA Parameters object.

Type:

mala.common.parametes.Parameters

add_hyperparameter(opttype='float', name='', low=0, high=0, choices=None)[source]

Add a hyperparameter to the current investigation.

Parameters:
  • opttype (string) –

    Datatype of the hyperparameter. Follows optuna’s naming conventions. In principle supported are:

    • float

    • int

    • categorical (list)

    Float and int are not available for OA based approaches at the moment.

  • name (string) – Name of the hyperparameter. Please note that these names always have to be distinct; if you e.g. want to investigate multiple layer sizes use e.g. ff_neurons_layer_001, ff_neurons_layer_002, etc. as names.

  • low (float or int) – Lower bound for numerical parameter.

  • high (float or int) – Higher bound for numerical parameter.

  • choices – List of possible choices (for categorical parameter).

classmethod checkpoint_exists(checkpoint_name, use_pkl_checkpoints=False)[source]

Check if a hyperparameter optimization checkpoint exists.

Returns True if it does.

Parameters:
  • checkpoint_name (string) – Name of the checkpoint.

  • use_pkl_checkpoints (bool) – If true, .pkl checkpoints will be loaded.

Returns:

checkpoint_exists – True if the checkpoint exists, False otherwise.

Return type:

bool

clear_hyperparameters()[source]

Clear the list of hyperparameters that are to be investigated.

abstract perform_study()[source]

Perform the study, i.e. the optimization.

This is done by sampling a certain subset of network architectures.

abstract set_optimal_parameters()[source]

Set the optimal parameters found in the present study.

The parameters will be written to the parameter object with which the hyperparameter optimizer was created.

set_parameters(trial)[source]

Set the parameters to a specific trial.

The parameters will be written to the parameter object with which the hyperparameter optimizer was created.