Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetaRL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wang, Mia
MetaRL
Commits
93995f95
Commit
93995f95
authored
2 years ago
by
Max Ramsay King
Browse files
Options
Downloads
Patches
Plain Diff
stuff gen again
parent
0ff5e107
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MetaAugment/autoaugment_learners/GenLearner.py
+10
-12
10 additions, 12 deletions
MetaAugment/autoaugment_learners/GenLearner.py
test_gen.py
+6
-5
6 additions, 5 deletions
test_gen.py
with
16 additions
and
17 deletions
MetaAugment/autoaugment_learners/
g
en
_l
earner.py
→
MetaAugment/autoaugment_learners/
G
en
L
earner.py
+
10
−
12
View file @
93995f95
...
...
@@ -171,38 +171,36 @@ class Genetic_learner(AaLearner):
def
generate_children
(
self
):
parent_acc
=
sorted
(
self
.
history
,
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
[:
self
.
sp_num
]
parent_acc
=
sorted
(
self
.
history
,
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
parents
=
[
x
[
0
]
for
x
in
parent_acc
]
parents_weights
=
[
x
[
1
]
for
x
in
parent_acc
]
new_pols
=
[]
for
_
in
range
(
self
.
num_offspring
):
parent1
,
parent2
=
self
.
choose_parents
(
parents
,
parents_weights
)
cross_over
=
random
.
randrange
(
1
,
len
(
parent2
),
1
)
cross_over
=
random
.
randrange
(
1
,
int
(
len
(
parent2
)
/
2
),
1
)
cross_over2
=
random
.
randrange
(
int
(
len
(
parent2
)
/
2
),
int
(
len
(
parent2
)),
1
)
child
=
parent1
[:
cross_over
]
child
+=
parent2
[
cross_over
:]
child
+=
parent2
[
cross_over
:
int
(
len
(
parent2
)
/
2
)]
child
+=
parent1
[
int
(
len
(
parent2
)
/
2
):
int
(
len
(
parent2
)
/
2
)
+
cross_over2
]
child
+=
parent2
[
int
(
len
(
parent2
)
/
2
)
+
cross_over2
:]
new_pols
.
append
(
child
)
return
new_pols
def
learn
(
self
,
train_dataset
,
test_dataset
,
child_network_architecture
,
iterations
=
10
):
def
learn
(
self
,
train_dataset
,
test_dataset
,
child_network_architecture
,
iterations
=
10
0
):
for
idx
in
range
(
iterations
):
print
(
"
iteration
:
"
,
idx
)
if
len
(
self
.
history
)
<
self
.
sp_
num
:
print
(
"
ITERATION
:
"
,
idx
)
if
len
(
self
.
history
)
<
self
.
num
_offspring
:
policy
=
[
self
.
gen_random_subpol
()]
else
:
policy
=
self
.
bin_to_subpol
(
random
.
choice
(
self
.
generate_children
()))
print
(
"
policyu:
"
,
policy
)
reward
=
self
.
_test_autoaugment_policy
(
policy
,
child_network_architecture
,
train_dataset
,
test_dataset
)
print
(
"
reward:
"
,
reward
)
print
(
"
new len hsitory:
"
,
len
(
self
.
history
))
print
(
"
hsitory:
"
,
self
.
history
)
print
(
"
reward:
"
,
reward
)
...
...
This diff is collapsed.
Click to expand it.
test_gen.py
+
6
−
5
View file @
93995f95
...
...
@@ -6,7 +6,7 @@ import torchvision
import
MetaAugment.child_networks
as
cn
from
MetaAugment.autoaugment_learners.AaLearner
import
AaLearner
from
MetaAugment.autoaugment_learners.
g
en
_l
earner
import
Genetic_learner
from
MetaAugment.autoaugment_learners.
G
en
L
earner
import
Genetic_learner
import
random
...
...
@@ -29,14 +29,15 @@ agent = Genetic_learner(
learning_rate
=
0.05
,
max_epochs
=
float
(
'
inf
'
),
early_stop_num
=
10
,
num_offspring
=
10
)
agent
.
learn
(
train_dataset
,
test_dataset
,
child_network_architecture
=
child_network_architecture
,
iterations
=
10
)
iterations
=
10
0
)
# with open('randomsearch_logs.pkl', 'wb') as file:
# pickle.dump(self.history, file)
print
(
agent
.
history
)
\ No newline at end of file
# with open('genetic_logs.pkl', 'wb') as file:
# pickle.dump(agent.history, file)
print
(
sorted
(
agent
.
history
,
key
=
lambda
x
:
x
[
1
]))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment