multiml.Hyperparameters

class multiml.Hyperparameters(hps=None)

Utility class to manage Hyperparameter classes.

The Hyperparameters class provides interfances to manage Hyperparameter class instances. This Hyperparameters class instance should be passed to TaskScheduler together with corresponding subtask.

Examples

>>> hps_dict = {
>>>     'hp_layers': [5, 10, 15, 20], # discrete
>>>     'hp_alpha': [1.0, 2.0, 3.0] # discrete
>>> }
>>> hps = Hyperparameters(hps_dict)
>>> hps.set_min_hps()
>>> hps.get_current_hps()
>>>  -> {'hp_layers': 5, 'hp_alpha': 1.0}
>>> hps.step('hp_layers', 2)
>>> hps.get_current_hps()
>>>  -> {'hp_layers': 15, 'hp_alpha': 1.0}
>>> hps.step('hp_alpha', 1)
>>> hps.get_current_hps()
>>>  -> {'hp_layers': 15, 'hp_alpha': 2.0}
__init__(hps=None)

Initialize Hyperparameters class.

hps option provides a shortcut to register hyperparameters. This option works only for discrete hyperparameters for now.

Parameters:

hps (dict) – a dictionary of hyperparameters. Please see add_hp_from_dict() method.

Methods

__init__([hps])

Initialize Hyperparameters class.

add_hp(name, values[, is_continuous])

Add hyperparameter.

add_hp_from_dict(hps)

Add hyperparameters from dictionary.

get_current_hps()

Returns the current values of Hyperparameters.

get_grid_hps()

Returns all possible combination of hyperparameters values.

get_hp_names()

Returns the names of hyperparameters.

set_max_hps()

Set the maximum value for each Hyperparameter.

set_min_hps()

Set the minimum value for each Hyperparameter.

step([hp_name, step])

Update the current hyperparameter values.

__init__(hps=None)

Initialize Hyperparameters class.

hps option provides a shortcut to register hyperparameters. This option works only for discrete hyperparameters for now.

Parameters:

hps (dict) – a dictionary of hyperparameters. Please see add_hp_from_dict() method.

__len__()

Returns the number of all possible combinations of hyperparameters.

__getitem__(item)

Returns registered Hyperparameter class instance by index.

If item is str, Hyperparameter is searched by its name, and class instance is returned if it exists. If item is int, a dictionary of selected hyperparameters from get_grid_hps() method is returned.

Parameters:

item (str or int) – the name of hyperparameter, or index of all possible combination from get_grid_hps() method.

Returns:

please see the above description.

Return type:

Hyperparameter or dict

__contains__(item)

Check if Hyperparameter is registered or not.

Parameters:

item (str) – the name of Hyperparameter.

Returns:

True if Hyperparameter exists.

Return type:

bool