Skip to content
Snippets Groups Projects
Commit 1ca017c3 authored by Max Ramsay King's avatar Max Ramsay King
Browse files

evo docs

parent af3f9759
No related branches found
No related tags found
No related merge requests found
Pipeline #272675 failed
......@@ -10,28 +10,85 @@ import autoaug.controller_networks as cont_n
class EvoLearner(AaLearner):
"""evo algorithm
"""Evolutionary Strategy learner
long explanatino here
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.
Args:
AaLearner (_type_): _description_
AaLearner:
Base class of all-auto augmentation learners.
sp_num: int, default 5
Number of subpolicies to keep in the final policy
p_bins: int, default 1
Number of probability bins for the controller network.
m_bins: int, default 1
Number of magnitude bins for the controller network
discrete_p_m: bool, default False
Boolean value to set if there are discrete or continuous
probability and mangitude bins (if False; p_bins, m_bins = 1)
exclude_method: list, default []
List of augmentations to be excluded from the search space
(Child Network Args)
learning_rate: float, default 1e-6
Learning rate of the child network
max_epochs: float, default float('inf')
Theoretical maximum number of epochs that the child network
can be trained on
early_stop_num: int, default 20
Criteria for early stopping. I.e. if the network has not improved
after early_stop_num iterations, the training is stopped
batch_size: int, default 8
Batch size for the datasets
toy_size: float, default 1
If a toy dataset is created, it will be of size toy_size compared
to the original dataset
(Evolutionary learner specific settings)
num_solutions: int, default 5
Number of offspring spawned at each generation of the algorithm
num_parents_mating: int, default 3
Number of networks chosen as parents for the next generation of networks
controller: Torch Network, default cont_n.EvoController
Controller network for the evolutionary algorithm
See Also
--------
Notes
-----
The Evolutionary algorithm runs in generations, and so batches of child networks
are trained at specific time intervals.
References
----------
Examples
--------
from autoaug.autoaugment_learners.EvlLearner import EvoLearner
evo_learner = EvoLearner()
"""
......
......@@ -195,6 +195,7 @@ class Genetic_learner(AaLearner):
policy = [self.gen_random_subpol()]
else:
policy = self.bin_to_subpol(random.choice(self.generate_children()))
print("Policy: ", policy)
reward = self._test_autoaugment_policy(policy,
child_network_architecture,
......
import pickle
with open('genetic_logs.pkl', 'rb') as f:
y = pickle.load(f)
accs = [x[1] for x in y]
print("accs: ", accs)
print("len accs: ", len(accs))
with open("genetic_accs.txt", "w") as output:
output.write(str(accs))
\ No newline at end of file
[0.6100000143051147, 0.7799999713897705, 0.6700000166893005, 0.1599999964237213, 0.7200000286102295, 0.7400000095367432, 0.550000011920929, 0.5600000023841858, 0.6000000238418579, 0.550000011920929, 0.699999988079071, 0.3700000047683716, 0.699999988079071, 0.7699999809265137, 0.6800000071525574, 0.38999998569488525, 0.7400000095367432, 0.5799999833106995, 0.3700000047683716, 0.4699999988079071, 0.7099999785423279, 0.6399999856948853, 0.6200000047683716, 0.6200000047683716, 0.6899999976158142, 0.7099999785423279, 0.1599999964237213, 0.49000000953674316, 0.7099999785423279, 0.3700000047683716, 0.699999988079071, 0.6299999952316284, 0.75, 0.6700000166893005, 0.6600000262260437, 0.7400000095367432, 0.6299999952316284, 0.5099999904632568, 0.5099999904632568, 0.1599999964237213, 0.6700000166893005, 0.38999998569488525, 0.6600000262260437, 0.5699999928474426, 0.5799999833106995, 0.3400000035762787, 0.5400000214576721, 0.6100000143051147, 0.09000000357627869, 0.75, 0.7900000214576721, 0.6800000071525574, 0.1599999964237213, 0.5099999904632568, 0.6800000071525574, 0.5, 0.6299999952316284, 0.7300000190734863, 0.6399999856948853, 0.7400000095367432, 0.5799999833106995, 0.7699999809265137, 0.6399999856948853, 0.7099999785423279, 0.49000000953674316, 0.30000001192092896, 0.7200000286102295, 0.46000000834465027, 0.6200000047683716, 0.4399999976158142, 0.1599999964237213, 0.23000000417232513, 0.6899999976158142, 0.1599999964237213, 0.7300000190734863, 0.7099999785423279, 0.800000011920929, 0.46000000834465027, 0.7099999785423279, 0.7300000190734863, 0.2199999988079071, 0.6700000166893005, 0.7099999785423279, 0.4000000059604645, 0.5400000214576721, 0.4300000071525574, 0.75, 0.1599999964237213, 0.6399999856948853, 0.6399999856948853, 0.6499999761581421, 0.7900000214576721, 0.7400000095367432, 0.6399999856948853, 0.5899999737739563, 0.7099999785423279, 0.5199999809265137, 0.5, 0.7099999785423279, 0.6299999952316284]
\ No newline at end of file
No preview for this file type
......@@ -15,14 +15,29 @@ import pickle
# train=True, download=True, transform=None)
# test_dataset = datasets.MNIST(root='./datasets/mnist/test',
# train=False, download=True, transform=torchvision.transforms.ToTensor())
train_dataset = datasets.FashionMNIST(root='./datasets/fashionmnist/train',
# train_dataset = datasets.FashionMNIST(root='./datasets/fashionmnist/train',
# train=True, download=True, transform=None)
# test_dataset = datasets.FashionMNIST(root='./datasets/fashionmnist/test',
# train=False, download=True,
# transform=torchvision.transforms.ToTensor())
train_dataset = datasets.CIFAR10(root='./datasets/cifar10/train',
train=True, download=True, transform=None)
test_dataset = datasets.FashionMNIST(root='./datasets/fashionmnist/test',
train=False, download=True,
test_dataset = datasets.CIFAR10(root='./datasets/cifar10/train',
train=False, download=True,
transform=torchvision.transforms.ToTensor())
child_network_architecture = cn.lenet
# child_network_architecture = cn.lenet()
child_network_architecture = cn.LeNet(
img_height=32,
img_width=32,
num_labels=10,
img_channels=3
)
agent = Genetic_learner(
sp_num=2,
toy_size=0.01,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment