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
563fec38
Commit
563fec38
authored
2 years ago
by
Sun Jin Kim
Browse files
Options
Downloads
Patches
Plain Diff
write ucb_learner.get_mega_policy() and its test
parent
53d0d751
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#272327
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MetaAugment/autoaugment_learners/ucb_learner.py
+26
-0
26 additions, 0 deletions
MetaAugment/autoaugment_learners/ucb_learner.py
test/MetaAugment/test_ucb_learner.py
+3
-0
3 additions, 0 deletions
test/MetaAugment/test_ucb_learner.py
with
29 additions
and
0 deletions
MetaAugment/autoaugment_learners/ucb_learner.py
+
26
−
0
View file @
563fec38
...
...
@@ -147,7 +147,33 @@ class ucb_learner(randomsearch_learner):
print
(
self
.
cnts
)
def
get_mega_policy
(
self
,
number_policies
):
"""
Produces a mega policy, based on the n best subpolicies (evo learner)/policies
(other learners)
Args:
number_policies -> int: Number of (sub)policies to be included in the mega
policy
Returns:
megapolicy -> [subpolicy, subpolicy, ...]
"""
temp_avg_accs
=
[
x
if
x
is
not
None
else
0
for
x
in
self
.
avg_accs
]
temp_history
=
list
(
zip
(
self
.
policies
,
temp_avg_accs
))
number_policies
=
max
(
number_policies
,
len
(
temp_history
))
inter_pol
=
sorted
(
temp_history
,
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)[:
number_policies
]
megapol
=
[]
for
pol
in
inter_pol
:
megapol
+=
pol
[
0
]
return
megapol
...
...
This diff is collapsed.
Click to expand it.
test/MetaAugment/test_ucb_learner.py
+
3
−
0
View file @
563fec38
...
...
@@ -52,5 +52,8 @@ def test_ucb_learner():
iterations
=
7
)
print
(
learner
.
get_mega_policy
(
number_policies
=
50
))
print
(
learner
.
get_mega_policy
(
number_policies
=
3
))
if
__name__
==
"
__main__
"
:
test_ucb_learner
()
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