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
21fc9bce
Commit
21fc9bce
authored
3 years ago
by
Sun Jin Kim
Browse files
Options
Downloads
Patches
Plain Diff
Demo code on main.py
parent
7f8fc18d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MetaAugment/CP2_Max.py
+4
-4
4 additions, 4 deletions
MetaAugment/CP2_Max.py
MetaAugment/__pycache__/main.cpython-38.pyc
+0
-0
0 additions, 0 deletions
MetaAugment/__pycache__/main.cpython-38.pyc
MetaAugment/main.py
+15
-19
15 additions, 19 deletions
MetaAugment/main.py
with
19 additions
and
23 deletions
MetaAugment/CP2_Max.py
+
4
−
4
View file @
21fc9bce
...
...
@@ -96,11 +96,11 @@ def train_model(transform_idx, p):
# create toy dataset from above uploaded data
train_loader
,
test_loader
=
create_toy
(
train_dataset
,
test_dataset
,
batch_size
,
0.01
)
train_loader
=
torch
.
utils
.
data
.
DataLoader
(
reduced_train_dataset
,
batch_size
=
batch_size
)
test_loader
=
torch
.
utils
.
data
.
DataLoader
(
reduced_test_dataset
,
batch_size
=
batch_size
)
#
train_loader = torch.utils.data.DataLoader(reduced_train_dataset, batch_size=batch_size)
#
test_loader = torch.utils.data.DataLoader(reduced_test_dataset, batch_size=batch_size)
print
(
"
Size of training dataset:
\t
"
,
len
(
reduced_train_dataset
))
print
(
"
Size of testing dataset:
\t
"
,
len
(
reduced_test_dataset
),
"
\n
"
)
#
print("Size of training dataset:\t", len(reduced_train_dataset))
#
print("Size of testing dataset:\t", len(reduced_test_dataset), "\n")
child_network
=
child_networks
.
lenet
()
sgd
=
optim
.
SGD
(
child_network
.
parameters
(),
lr
=
1e-1
)
...
...
This diff is collapsed.
Click to expand it.
MetaAugment/__pycache__/main.cpython-38.pyc
+
0
−
0
View file @
21fc9bce
No preview for this file type
This diff is collapsed.
Click to expand it.
MetaAugment/main.py
+
15
−
19
View file @
21fc9bce
...
...
@@ -77,28 +77,24 @@ def train_child_network(child_network, train_loader, test_loader, sgd,
return
best_acc
# This is sort of how our AA_Learner class should look like:
class
AA_Learner
:
def
__init__
(
self
,
controller
):
self
.
controller
=
controller
def
learn
(
self
,
train_dataset
,
test_dataset
,
child_network
,
toy_flag
):
'''
Deos what is seen in Figure 1 in the AutoAugment paper.
if
__name__
==
'
__main__
'
:
import
MetaAugment.child_networks
as
cn
'
res
'
stands for resolution of the discretisation of the search space. It could be
a tuple, with first entry regarding probability, second regarding magnitude
'''
good_policy_found
=
False
batch_size
=
32
n_samples
=
0.005
while
not
good_policy_found
:
policy
=
self
.
controller
.
pop_policy
()
train_dataset
=
datasets
.
MNIST
(
root
=
'
./datasets/mnist/train
'
,
train
=
True
,
download
=
False
,
transform
=
torchvision
.
transforms
.
ToTensor
())
test_dataset
=
datasets
.
MNIST
(
root
=
'
./datasets/mnist/test
'
,
train
=
False
,
download
=
False
,
transform
=
torchvision
.
transforms
.
ToTensor
())
train_loader
,
test_loader
=
create
_
toy
(
train_dataset
,
test_dataset
,
batch_size
=
32
,
n_samples
=
0.0
05
)
#
create
toy
dataset from above uploaded data
train_loader
,
test_loader
=
create_toy
(
train_dataset
,
test_dataset
,
batch_size
,
0.0
1
)
reward
=
train_child_network
(
child_network
,
train_loader
,
test_loader
,
sgd
,
cost
,
epoch
)
child_network
=
cn
.
lenet
()
sgd
=
optim
.
SGD
(
child_network
.
parameters
(),
lr
=
1e-1
)
cost
=
nn
.
CrossEntropyLoss
()
epoch
=
20
self
.
controller
.
update
(
reward
,
policy
)
return
good_policy
\ No newline at end of file
best_acc
=
train_child_network
(
child_network
,
train_loader
,
test_loader
,
sgd
,
cost
,
max_epochs
=
100
)
\ 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