HyperParameterSet#

class mergernet.core.hp.HyperParameterSet[source]#

Bases: object

Represents a set of hyperparameters and handles the hyperparameters register and access.

Parameters:

*args (HyperParameter) – Any HyperParameter instance created by HP factory

add(hyperparameters: Sequence[dict | HyperParameter])[source]#

Parses a sequence of dictionaries that represents the hyperparameters

Parameters:

hyperparameters (array-like of dictionaries or arrar-like of HyperParameter) – The list of hyperparameters that will be added to this hyperparameters set

clear_values_dict()[source]#

Clear last_value property of the hyperparameter, relevant when training with conditional hyperparameters

get(name: str, trial: FrozenTrial | None = None, default: Any | None = None) Any[source]#

Get the value of a hyperparameter identified by its name. For hyperparameters different than ConstantHyperParameter, this method will use optuna’s seggest api

Parameters:
  • name (str) – The hyperparamer name

  • trial (optuna.trial.FrozenTrial) – The optuan trial instance

  • default (Any) – Default value returned if the specified hyperparameter name wasn’t found

Returns:

The hyperparameter value

Return type:

Any

set_trial(trial: FrozenTrial)[source]#

Sets the optuna’s trial for all hyperparameter in this set

Parameters:

trial (optuna.trial.FrozenTrial) – The trial that will be added

to_values_dict()[source]#

Returns a dict representation of this hyperparameters set with hp name as dict key and last optuna’s suggested value as dict value