From 5bb0d1c0b815c98048ad7100286d573d83909723 Mon Sep 17 00:00:00 2001 From: Max Ramsay King <maxramsayking@gmail.com> Date: Wed, 20 Apr 2022 15:13:39 -0700 Subject: [PATCH] logging info --- .../test/cifar-10-batches-py/batches.meta | Bin 0 -> 158 bytes .../test/cifar-10-batches-py/readme.html | 1 + .../train/cifar-10-batches-py/batches.meta | Bin 0 -> 158 bytes .../train/cifar-10-batches-py/readme.html | 1 + .../autoaugment_learners/evo_learner.py | 37 ++++++++++-------- 5 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 MetaAugment/MetaAugment/test/cifar-10-batches-py/batches.meta create mode 100644 MetaAugment/MetaAugment/test/cifar-10-batches-py/readme.html create mode 100644 MetaAugment/MetaAugment/train/cifar-10-batches-py/batches.meta create mode 100644 MetaAugment/MetaAugment/train/cifar-10-batches-py/readme.html diff --git a/MetaAugment/MetaAugment/test/cifar-10-batches-py/batches.meta b/MetaAugment/MetaAugment/test/cifar-10-batches-py/batches.meta new file mode 100644 index 0000000000000000000000000000000000000000..4467a6ec2e886a9f14f25e31776fb0152d8ac64a GIT binary patch literal 158 zcmWm8OAdlC5CBkxA_(|NJcO*g3CmfUW?DvQER^ZTory<RS8w}1*_*c=T$VITje&w( z$xDS%Pn`AVD>N1rS-Id$f%7|y4k|Q$wYU%$P-BX2cFI`d9SCLoz$N4wBUc~>BF}rs o2RCvJ;^BWbP)yDT;ub`h%*qESqEGtCM}qSIc$vVbe$%Gg7eB5uW&i*H literal 0 HcmV?d00001 diff --git a/MetaAugment/MetaAugment/test/cifar-10-batches-py/readme.html b/MetaAugment/MetaAugment/test/cifar-10-batches-py/readme.html new file mode 100644 index 00000000..e377adef --- /dev/null +++ b/MetaAugment/MetaAugment/test/cifar-10-batches-py/readme.html @@ -0,0 +1 @@ +<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.cs.toronto.edu/~kriz/cifar.html"> diff --git a/MetaAugment/MetaAugment/train/cifar-10-batches-py/batches.meta b/MetaAugment/MetaAugment/train/cifar-10-batches-py/batches.meta new file mode 100644 index 0000000000000000000000000000000000000000..4467a6ec2e886a9f14f25e31776fb0152d8ac64a GIT binary patch literal 158 zcmWm8OAdlC5CBkxA_(|NJcO*g3CmfUW?DvQER^ZTory<RS8w}1*_*c=T$VITje&w( z$xDS%Pn`AVD>N1rS-Id$f%7|y4k|Q$wYU%$P-BX2cFI`d9SCLoz$N4wBUc~>BF}rs o2RCvJ;^BWbP)yDT;ub`h%*qESqEGtCM}qSIc$vVbe$%Gg7eB5uW&i*H literal 0 HcmV?d00001 diff --git a/MetaAugment/MetaAugment/train/cifar-10-batches-py/readme.html b/MetaAugment/MetaAugment/train/cifar-10-batches-py/readme.html new file mode 100644 index 00000000..e377adef --- /dev/null +++ b/MetaAugment/MetaAugment/train/cifar-10-batches-py/readme.html @@ -0,0 +1 @@ +<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.cs.toronto.edu/~kriz/cifar.html"> diff --git a/MetaAugment/autoaugment_learners/evo_learner.py b/MetaAugment/autoaugment_learners/evo_learner.py index f0e3a597..b4c2e4be 100644 --- a/MetaAugment/autoaugment_learners/evo_learner.py +++ b/MetaAugment/autoaugment_learners/evo_learner.py @@ -29,7 +29,6 @@ class evo_learner(): batch_size=8, toy_flag=False, toy_size=0.1, - sub_num_pol=5, fun_num = 14, exclude_method=[], ): @@ -46,15 +45,15 @@ class evo_learner(): max_epochs=max_epochs, early_stop_num=early_stop_num,) - - self.auto_aug_agent = Evo_learner(fun_num=fun_num, p_bins=p_bins, m_bins=m_bins, sub_num_pol=sub_num_pol) + self.num_solutions = num_solutions + self.auto_aug_agent = Evo_learner(fun_num=fun_num, p_bins=p_bins, m_bins=m_bins, sub_num_pol=sp_num) self.torch_ga = torchga.TorchGA(model=self.auto_aug_agent, num_solutions=num_solutions) self.num_parents_mating = num_parents_mating self.initial_population = self.torch_ga.population_weights self.train_loader = train_loader self.child_network = child_network self.p_bins = p_bins - self.sub_num_pol = sub_num_pol + self.sub_num_pol = sp_num self.m_bins = m_bins self.fun_num = fun_num self.augmentation_space = [x for x in augmentation_space if x[0] not in exclude_method] @@ -121,15 +120,15 @@ class evo_learner(): """ section = self.auto_aug_agent.fun_num + self.auto_aug_agent.p_bins + self.auto_aug_agent.m_bins - y = self.auto_aug_agent.forward(x) # 1000 x 32 + y = self.auto_aug_agent.forward(x) - y_1 = torch.softmax(y[:,:self.auto_aug_agent.fun_num], dim = 1) # 1000 x 14 + y_1 = torch.softmax(y[:,:self.auto_aug_agent.fun_num], dim = 1) y[:,:self.auto_aug_agent.fun_num] = y_1 y_2 = torch.softmax(y[:,section:section+self.auto_aug_agent.fun_num], dim = 1) y[:,section:section+self.auto_aug_agent.fun_num] = y_2 concat = torch.cat((y_1, y_2), dim = 1) - cov_mat = torch.cov(concat.T)#[:self.auto_aug_agent.fun_num, self.auto_aug_agent.fun_num:] + cov_mat = torch.cov(concat.T) cov_mat = cov_mat[:self.auto_aug_agent.fun_num, self.auto_aug_agent.fun_num:] shape_store = cov_mat.shape @@ -197,9 +196,16 @@ class evo_learner(): Solution_idx -> Int """ self.num_generations = iterations + self.running_best = [0 for i in range(iterations)] + self.running_avg = [0 for i in range(iterations)] + self.gen_count = 0 + self.best_model = 0 + self.set_up_instance() self.ga_instance.run() + self.running_avg = self.running_avg / self.num_solutions + solution, solution_fitness, solution_idx = self.ga_instance.best_solution() if return_weights: return torchga.model_weights_as_dict(model=self.auto_aug_agent, weights_vector=solution) @@ -207,14 +213,6 @@ class evo_learner(): return solution, solution_fitness, solution_idx - def new_model(self): - """ - Simple function to create a copy of the secondary model (used for classification) - """ - copy_model = copy.deepcopy(self.child_network) - return copy_model - - def set_up_instance(self, train_dataset, test_dataset): """ Initialises GA instance, as well as fitness and on_generation functions @@ -249,9 +247,15 @@ class evo_learner(): full_policy = self.get_full_policy(test_x) - fit_val = ((self.test_autoaugment_policy(full_policy, train_dataset, test_dataset)[0])/ + fit_val = ((self.test_autoaugment_policy(full_policy, train_dataset, test_dataset)[0]) / + self.test_autoaugment_policy(full_policy, train_dataset, test_dataset)[0]) / 2 + if fit_val > self.running_best[self.gen_count]: + self.running_best[self.gen_count] = fit_val + + self.running_avg[self.gen_count] += fit_val + + return fit_val def on_generation(ga_instance): @@ -267,6 +271,7 @@ class evo_learner(): None """ print("Generation = {generation}".format(generation=ga_instance.generations_completed)) + self.gen_count += 1 print("Fitness = {fitness}".format(fitness=ga_instance.best_solution()[1])) return -- GitLab