Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor NAS RL Suggestion #1134

Merged
merged 3 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

if num_gpus > 1:
test_model = multi_gpu_model(test_model, gpus=num_gpus)

test_model.summary()
test_model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adam(lr=1e-3, decay=1e-4),
Expand All @@ -61,7 +61,8 @@
width_shift_range=0.1,
height_shift_range=0.1,
horizontal_flip=True)


# TODO: Add batch size to args
aug_data_flow = augmentation.flow(x_train, y_train, batch_size=128)

print(">>> Data Loaded. Training starts.")
Expand Down
137 changes: 55 additions & 82 deletions examples/v1alpha3/nasjob-example-RL-cpu.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This CPU example aims to show all the possible operations
# is not very likely to get good result due to the extensive search space

# In practice, setting up a limited search space with more common operations is more likely to get better performance.
# In practice, setting up a limited search space with more common operations is more likely to get better performance.
# For example, Efficient Neural Architecture Search via Parameter Sharing (https://arxiv.org/abs/1802.03268)
# uses only 6 operations, 3x3/5x5 convolution, 3x3/5x5 separable_convolution and 3x3 max_pooling/avg_pooling.

Expand All @@ -23,58 +23,31 @@ spec:
objectiveMetricName: Validation-Accuracy
algorithm:
algorithmName: nasrl
algorithmSettings:
- name: "lstm_num_cells"
value: "64"
- name: "lstm_num_layers"
value: "1"
- name: "lstm_keep_prob"
value: "1.0"
- name: "optimizer"
value: "adam"
- name: "init_learning_rate"
value: "1e-3"
- name: "lr_decay_start"
value: "0"
- name: "lr_decay_every"
value: "1000"
- name: "lr_decay_rate"
value: "0.9"
- name: "skip-target"
value: "0.4"
- name: "skip-weight"
value: "0.8"
- name: "l2_reg"
value: "0"
- name: "entropy_weight"
value: "1e-4"
- name: "baseline_decay"
value: "0.9999"
trialTemplate:
goTemplate:
rawTemplate: |-
apiVersion: batch/v1
kind: Job
metadata:
name: {{.Trial}}
namespace: {{.NameSpace}}
spec:
template:
spec:
containers:
- name: {{.Trial}}
image: docker.io/kubeflowkatib/nasrl-cifar10-cpu
command:
- "python3.5"
- "-u"
- "RunTrial.py"
{{- with .HyperParameters}}
{{- range .}}
- "--{{.Name}}=\"{{.Value}}\""
{{- end}}
{{- end}}
- "--num_epochs=1"
restartPolicy: Never
rawTemplate: |-
apiVersion: batch/v1
kind: Job
metadata:
name: {{.Trial}}
namespace: {{.NameSpace}}
spec:
template:
spec:
containers:
- name: {{.Trial}}
image: docker.io/kubeflowkatib/nasrl-cifar10-cpu
command:
- "python3.5"
- "-u"
- "RunTrial.py"
{{- with .HyperParameters}}
{{- range .}}
- "--{{.Name}}=\"{{.Value}}\""
{{- end}}
{{- end}}
- "--num_epochs=1"
restartPolicy: Never
nasConfig:
graphConfig:
numLayers: 1
Expand All @@ -91,83 +64,83 @@ spec:
parameterType: categorical
feasibleSpace:
list:
- "3"
- "5"
- "7"
- "3"
- "5"
- "7"
- name: num_filter
parameterType: categorical
feasibleSpace:
list:
- "32"
- "48"
- "64"
- "96"
- "128"
- "32"
- "48"
- "64"
- "96"
- "128"
- name: stride
parameterType: categorical
feasibleSpace:
list:
- "1"
- "2"
- "1"
- "2"
- operationType: separable_convolution
parameters:
- name: filter_size
parameterType: categorical
feasibleSpace:
list:
- "3"
- "5"
- "7"
- "3"
- "5"
- "7"
- name: num_filter
parameterType: categorical
feasibleSpace:
list:
- "32"
- "48"
- "64"
- "96"
- "128"
- "32"
- "48"
- "64"
- "96"
- "128"
- name: stride
parameterType: categorical
feasibleSpace:
list:
- "1"
- "2"
- "1"
- "2"
- name: depth_multiplier
parameterType: categorical
feasibleSpace:
list:
- "1"
- "2"
- "1"
- "2"
- operationType: depthwise_convolution
parameters:
- name: filter_size
parameterType: categorical
feasibleSpace:
list:
- "3"
- "5"
- "7"
- "3"
- "5"
- "7"
- name: stride
parameterType: categorical
feasibleSpace:
list:
- "1"
- "2"
- "1"
- "2"
- name: depth_multiplier
parameterType: categorical
feasibleSpace:
list:
- "1"
- "2"
- "1"
- "2"
- operationType: reduction
parameters:
- name: reduction_type
parameterType: categorical
feasibleSpace:
list:
- max_pooling
- avg_pooling
- max_pooling
- avg_pooling
- name: pool_size
parameterType: int
feasibleSpace:
Expand Down
Loading