autoaug.autoaugment_learners.EvoLearner
- class autoaug.autoaugment_learners.EvoLearner(num_sub_policies=5, p_bins=1, m_bins=1, exclude_method=[], learning_rate=0.1, max_epochs=inf, early_stop_num=20, batch_size=8, toy_size=1, num_solutions=5, num_parents_mating=3, controller=<class 'autoaug.controller_networks.EvoController.EvoController'>)[source]
Evolutionary Strategy learner
This learner generates neural networks that predict optimal augmentation policies. Hence, there is no backpropagation or gradient descent. Instead, training is done by randomly changing weights of the ‘parent’ networks, where parents are determined by their ability to produce policies that increase the accuracy of the child network.
- Parameters
num_sub_policies (int, optional) – number of subpolicies per policy. Defaults to 5.
p_bins (int, optional) – number of bins we divide the interval [0,1] for probabilities. e.g. (0.0, 0.1, … 1.0) Defaults to 1.
m_bins (int, optional) – number of bins we divide the magnitude space. Defaults to 1.
exclude_method (list, optional) – list of names(:type:str) of image operations the user wants to exclude from the search space. Defaults to [].
batch_size (int, optional) – child_network training parameter. Defaults to 32.
toy_size (int, optional) – child_network training parameter. ratio of original dataset used in toy dataset. Defaults to 0.1.
learning_rate (float, optional) – child_network training parameter. Defaults to 1e-1.
max_epochs (Union[int, float], optional) – child_network training parameter. Defaults to float(‘inf’).
early_stop_num (int, optional) – child_network training parameter. Defaults to 20.
num_solutions (int, optional) – Number of offspring spawned at each generation of the algorithm. Default 5
num_parents_mating (int, optional) – Number of networks chosen as parents for the next generation of networks Defaults to 3
controller (nn.Module, optional) – Controller network for the evolutionary algorithm. Defaults to cont_n.EvoController
Notes
The Evolutionary algorithm runs in generations, and so batches of child networks are trained at specific time intervals.
Examples
from autoaug.autoaugment_learners.EvlLearner import EvoLearner evo_learner = EvoLearner()
- learn(train_dataset, test_dataset, child_network_architecture, iterations=15, return_weights=False)[source]
Runs the GA instance and returns the model weights as a dictionary
- Parameters
bool (return_weights ->) – Determines if the weight of the GA network should be returned
- Returns
If return_weights – Network weights -> dict
Else – Solution -> Best GA instance solution
Solution fitness -> float
Solution_idx -> int