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
d6f15d90
Commit
d6f15d90
authored
2 years ago
by
Sun Jin Kim
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
df39cc2d
No related branches found
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/aa_learner.py
+10
-8
10 additions, 8 deletions
MetaAugment/autoaugment_learners/aa_learner.py
MetaAugment/autoaugment_learners/gru_learner.py
+6
-5
6 additions, 5 deletions
MetaAugment/autoaugment_learners/gru_learner.py
with
16 additions
and
13 deletions
MetaAugment/autoaugment_learners/aa_learner.py
+
10
−
8
View file @
d6f15d90
...
...
@@ -217,7 +217,8 @@ class aa_learner:
which is:
1. <generate a random policy>
2. <see how good that policy is>
3. <save how good the policy is in a list/dictionary>
3. <save how good the policy is in a list/dictionary and
(if applicable,) update the controller (e.g. RL agent)>
Args:
train_dataset (torchvision.dataset.vision.VisionDataset)
...
...
@@ -234,16 +235,17 @@ class aa_learner:
"""
# This is dummy code
# test out 15 random policies
for
_
in
range
(
15
):
policy
=
self
.
generate_new_policy
()
#
for _ in range(15):
#
policy = self.generate_new_policy()
pprint
(
policy
)
child_network
=
child_network_architecture
()
reward
=
self
.
test_autoaugment_policy
(
policy
,
child_network
,
train_dataset
,
test_dataset
,
toy_flag
)
#
pprint(policy)
#
child_network = child_network_architecture()
#
reward = self.test_autoaugment_policy(policy, child_network, train_dataset,
#
test_dataset, toy_flag)
self
.
history
.
append
((
policy
,
reward
))
#
self.history.append((policy, reward))
def
test_autoaugment_policy
(
self
,
policy
,
child_network
,
train_dataset
,
test_dataset
,
...
...
This diff is collapsed.
Click to expand it.
MetaAugment/autoaugment_learners/gru_learner.py
+
6
−
5
View file @
d6f15d90
...
...
@@ -71,7 +71,8 @@ class gru_learner(aa_learner):
contains information regarding which
'
image function
'
to use,
which value of
'
probability(prob)
'
and
'
magnitude(mag)
'
to use.
We run the GRU for 10 timesteps to obtain 10 of such tensors.
We run the GRU for 2*self.sp_num timesteps to obtain 2*self.sp_num
of such tensors.
We then softmax the parts of the tensor which represents the
choice of function, prob, and mag seperately, so that the
...
...
@@ -135,11 +136,11 @@ class gru_learner(aa_learner):
return
new_policy
,
log_prob
def
learn
(
self
,
train_dataset
,
test_dataset
,
child_network_architecture
,
toy_flag
,
m
=
8
):
def
learn
(
self
,
train_dataset
,
test_dataset
,
child_network_architecture
,
toy_flag
,
m
b_size
=
8
):
# optimizer for training the GRU controller
cont_optim
=
torch
.
optim
.
SGD
(
self
.
controller
.
parameters
(),
lr
=
1e-2
)
m
=
8
# minibatch size
m
b_size
=
8
# minibatch size
b
=
0.88
# b is the running exponential mean of the rewards, used for training stability
# (see section 3.2 of https://arxiv.org/abs/1611.01578)
...
...
@@ -153,7 +154,7 @@ class gru_learner(aa_learner):
# sum up the rewards within a minibatch in order to update the running mean, 'b'
mb_rewards_sum
=
0
for
k
in
range
(
m
):
for
k
in
range
(
m
b_size
):
# log_prob is $\sum_{t=1}^T log(P(a_t|a_{(t-1):1};\theta_c))$, used in PPO
policy
,
log_prob
=
self
.
generate_new_policy
()
...
...
@@ -170,7 +171,7 @@ class gru_learner(aa_learner):
obj
+=
(
reward
-
b
)
*
log_prob
# update running mean of rewards
b
=
0.7
*
b
+
0.3
*
(
mb_rewards_sum
/
m
)
b
=
0.7
*
b
+
0.3
*
(
mb_rewards_sum
/
m
b_size
)
(
-
obj
).
backward
()
# We put a minus because we want to maximize the objective, not
# minimize it.
...
...
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