Mutant-UCB

Mutant-UCB#

class Mutant_UCB(search_space, T, K, N, E, evaluation, save_dir, models=None, pop_path=None, verbose=False, **args)[source]

Bases: SearchAlgorithm

Search algorithm implementing the Mutant-UCB search algorithm inheriting from the SearchAlgorithm class. It implements a select_next_configuration and a process_evaluated_configuration methods, specific to Mutant-UCB.

Parameters:
  • search_space (Variable) – Variable containing all the design choices from the search space. It should implement a random method and a neighbor one.

  • T (int) – Number of iterations.

  • K (int) – Size of the population.

  • N (int) – Maximum number of partial training for one configuration.

  • E (float) – Exploratory parameters.

  • evaluation (function) – Performance evaluation function. Takes as argument a set of configuration and the unique index of this configuration. Returns the performance and the model built.

  • save_dir (str) – Path towards saving directory. If not empty, the content will be replaced.

  • models (list, default=None) – List of configurations that should be included into the initial population.

  • pop_path (str, default=None) – Path towards a directory containing an former evaluation that we aim to continue.

  • verbose (bool, default=False) – Verbose boolean.

N

Maximum number of partial training for one configuration.

Type:

int

E

Exploratory parameters.

Type:

float

sent

Dictionary containing the configurations that are currently evaluated and thus are temporarly removed from the population.

Type:

dict, default={}

search_space

Variable containing all the design choices from the search space. It should implement a random method and a neighbor one if necessary.

Type:

Variable

n_iterations

Number of iterations.

Type:

int

population_size

Size of the randomly initialized population.

Type:

int

evaluation

Performance evaluation function. Takes as argument a set of configuration and the unique index of this configuration. Returns the performance and the model built.

Type:

function

save_dir

Path towards saving directory. If not empty, the content will be replaced.

Type:

str

models

List of configurations that should be included into the initial population.

Type:

list, default=None

pop_path

Path towards a directory containing an former evaluation that we aim to continue.

Type:

str, default=None

verbose

Verbose boolean.

Type:

bool, default=False

run

Run function to use: MPI (run_mpi) or not (run_no_mpi).

Type:

function

set_mpi

Dictionary containing the MPI parameters.

Type:

dict

storage

Dictionary storing the configurations from the population.

Type:

dict, default={}

min_loss

Current minimum loss found.

Type:

float, default=np.min

Example

>>> from dragon.search_space.base_variables import ArrayVar
>>> from dragon.search_operators.base_neighborhoods import ArrayInterval
>>> from dragon.search_algorithm.mutant_ucb import Mutant_UCB
>>> search_space = ArrayVar(dag, label="Search Space", neighbor=ArrayInterval())
>>> search_algorithm = Mutant_UCB(search_space, save_dir="save/test_mutant", T=20, N=5, K=5, E=0.01, evaluation=loss_function)
>>> search_algorithm.run()
select_next_configurations()[source]

Defines a selection strategy for Mutant-UCB. Select the next configuration optimistically: the minimum loss + UCB interval. With a certain probability remove the configuration from self.storage and add it to self.sent to perform a new partial training. If not, increments the number of time the configuration has been picked, creates a new configuration using the neighbor attribute, increments the number of models within the population self.K and add the configuration to self.sent.

Returns:

[idx] – List containing the idx of the selected configuration.

Return type:

list

process_evaluated_configuration(idx, loss)[source]

Defines how to process the last evaluated configuration given its loss. Save the current loss, average loss according to previous evaluations. Increments the number of time the configuration has been picked and evaluated. Removes the configuration from self.sent and add it to self.storage.

Parameters:
  • idx (int) – Index of the configuration.

  • loss (float) – Loss of the evaluation.

Returns:

  • delete (False) – Boolean indicating if the configuration extra-information should be deleted. In Mutant-UCB, all evaluated configurations are kept.

  • row_pop (dict) – Dictionary containing evaluation information to be saved within a .csv file called computation_file.csv.

  • loss (float) – Average loss across all evaluations.

process_evaluated_row(row)[source]

Modifies the process_evaluated_row method from SearchAlgorithm to add the extra information contained by computation_file.csv. Add the average loss, the number of times the configuration has been picked and evaluated to the self.storage dictionary.

Parameters:

row (dict) – Dictionary containing the information of an evaluated configuration.