Skip to content

search

train

Train the neural architecture.

Searcher

The base class to search for neural architectures. This class generate new architectures, call the trainer to train it, and update the optimizer.

Attributes
  • n_classes: Number of classes in the target classification task.

  • input_shape: Arbitrary, although all dimensions in the input shaped must be fixed. Use the keyword argument input_shape (tuple of integers, does not include the batch axis) when using this layer as the first layer in a model.

  • verbose: Verbosity mode.

  • history: A list that stores the performance of model. Each element in it is a dictionary of 'model_id', 'loss', and 'metric_value'.

  • neighbour_history: A list that stores the performance of neighbor of the best model. Each element in it is a dictionary of 'model_id', 'loss', and 'metric_value'.

  • path: A string. The path to the directory for saving the searcher.

  • metric: An instance of the Metric subclasses.

  • loss: A function taking two parameters, the predictions and the ground truth.

  • generators: A list of generators used to initialize the search.

  • model_count: An integer. the total number of neural networks in the current searcher.

  • descriptors: A dictionary of all the neural network architectures searched.

  • trainer_args: A dictionary. The params for the constructor of ModelTrainer.

  • default_model_len: An integer. Number of convolutional layers in the initial architecture.

  • default_model_width: An integer. The number of filters in each layer in the initial architecture.

  • training_queue: A list of the generated architectures to be trained.

  • x_queue: A list of trained architectures not updated to the gpr.

  • y_queue: A list of trained architecture performances not updated to the gpr.

init

Initialize the Searcher.

Args
  • n_output_node: An integer, the number of classes.

  • input_shape: A tuple. e.g. (28, 28, 1).

  • path: A string. The path to the directory to save the searcher.

  • metric: An instance of the Metric subclasses.

  • loss: A function taking two parameters, the predictions and the ground truth.

  • generators: A list of generators used to initialize the search.

  • verbose: A boolean. Whether to output the intermediate information to stdout.

  • trainer_args: A dictionary. The params for the constructor of ModelTrainer.

  • default_model_len: An integer. Number of convolutional layers in the initial architecture.

  • default_model_width: An integer. The number of filters in each layer in the initial architecture.

Call the generators to generate the initial architectures for the search.

Run the search loop of training, generating and updating once. The function will run the training and generate in parallel. Then it will update the controller. The training is just pop out a graph from the training_queue and train it. The generate will call the self.generate function. The update will call the self.update function.

Args
  • train_data: An instance of DataLoader.

  • test_data: An instance of Dataloader.

  • timeout: An integer, time limit in seconds.

generate

Generate the next neural architecture.

Args
  • multiprocessing_queue: the Queue for multiprocessing return value.
Returns
  • list of 2-element tuples: generated_graph and other_info,

  • generated_graph: An instance of Graph.

  • other_info: Anything to be saved in the training queue together

add_model

Append the information of evaluated architecture to history.

BayesianSearcher

Class to search for neural architectures using Bayesian search strategy. Attribute: optimizer: An instance of BayesianOptimizer. t_min: A float. The minimum temperature during simulated annealing.

generate

Generate the next neural architecture.

Args
  • multiprocessing_queue: the Queue for multiprocessing return value.
Returns
  • list of 2-element tuples: generated_graph and other_info,

  • generated_graph: An instance of Graph.

  • other_info: Anything to be saved in the training queue together with the architecture.

update

Update the controller with evaluation result of a neural architecture.

Args
  • other_info: Anything. In our case it is the father ID in the search tree.

  • model_id: An integer.

  • graph: An instance of Graph. The trained neural architecture.

  • metric_value: The final evaluated metric value.