autoaug.autoaugment_learners.UcbLearner
- class autoaug.autoaugment_learners.UcbLearner(num_sub_policies=5, p_bins=11, m_bins=10, exclude_method=[], batch_size=8, toy_size=1, learning_rate=0.1, max_epochs=inf, early_stop_num=30, num_policies=100)[source]
Uses the UCB1 algorithm originally developed for multi-armed bandit problems. Recommended when
Optimal hyperparameters for training the CNN (such as batch size and learning rate) has not been found yet.
Using a toy dataset or a toy CNN
- 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 11.
m_bins (int, optional) – number of bins we divide the magnitude space. Defaults to 10.
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-2.
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_policies (int, optional) – Number of policies we want to serach over. Defaults to 100.
- history
list of policies that has been input into self._test_autoaugment_policy as well as their respective obtained accuracies
- Type
- augmentation_space
list of image functions that the user has chosen to include in the search space.
- Type
- avg_accs
A list where the nth element indicates the average accuracy obtained by the nth policy.
- Type
Notes
As opposed the the other learners, this searches over a subset of the entire search space (specified in the AutoAugment paper). The size of the subset is initialized to be
self.num_policies. But we can increase it by running self.make_more_policies(). For example, we initialize the learner withself.num_policies=7, runself.learn(iterations=20)to learn about the seven policies we have in ourself.policies. Then runself.make_more_policies(n=5)to add 5 more policies toself.policies. Then we can runself.learn(iterations=20)to continue the UCB1 algorithm with the extended search space.References
- Peter Auer, et al.
“Finite-time Analysis of the Multiarmed Bandit Problem” https://homes.di.unimi.it/~cesabian/Pubblicazioni/ml-02.pdf
- get_mega_policy(number_policies=5)[source]
Produces a mega policy, based on the n best subpolicies (evo learner)/policies (other learners)
- Parameters
int (number_policies ->) – Number of (sub)policies to be included in the mega
policy –
- Returns
megapolicy -> [subpolicy, subpolicy, …]
- get_n_best_policies(number_policies=5)[source]
returns the n best policies
- Parameters
number_policies (int) – Number of (sub)policies to return
- Returns
list of best n policies