forked from microsoft/nni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge dev-nas-tuner back to master (microsoft#1531)
* PPO tuner for NAS, supports NNI's NAS interface (microsoft#1380)
- Loading branch information
1 parent
7246593
commit 55f48d2
Showing
41 changed files
with
3,292 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
PPO Tuner on NNI | ||
=== | ||
|
||
## PPOTuner | ||
|
||
This is a tuner generally for NNI's NAS interface, it uses [ppo algorithm](https://arxiv.org/abs/1707.06347). The implementation inherits the main logic of the implementation [here](https://github.com/openai/baselines/tree/master/baselines/ppo2) (i.e., ppo2 from OpenAI), and is adapted for NAS scenario. | ||
|
||
It could successfully tune the [mnist-nas example](https://github.com/microsoft/nni/tree/master/examples/trials/mnist-nas), and has the following result: | ||
|
||
![](../../img/ppo_mnist.png) | ||
|
||
We also tune [the macro search space for image classification in the enas paper](https://github.com/microsoft/nni/tree/master/examples/trials/nas_cifar10) (with limited epoch number for each trial, i.e., 8 epochs), which is implemented using the NAS interface and tuned with PPOTuner. Use Figure 7 in the [enas paper](https://arxiv.org/pdf/1802.03268.pdf) to show how the search space looks like | ||
|
||
![](../../img/enas_search_space.png) | ||
|
||
The figure above is a chosen architecture, we use it to show how the search space looks like. Each square is a layer whose operation can be chosen from 6 operations. Each dash line is a skip connection, each square layer could choose 0 or 1 skip connection getting the output of a previous layer. __Note that__ in original macro search space each square layer could choose any number of skip connections, while in our implementation it is only allowed to choose 0 or 1. | ||
|
||
The result is shown in figure below (with the experiment config [here](https://github.com/microsoft/nni/blob/master/examples/trials/nas_cifar10/config_ppo.yml)): | ||
|
||
![](../../img/ppo_cifar10.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
authorName: default | ||
experimentName: example_mnist | ||
trialConcurrency: 1 | ||
maxExecDuration: 1h | ||
maxTrialNum: 10 | ||
#choice: local, remote, pai | ||
trainingServicePlatform: local | ||
#choice: true, false | ||
useAnnotation: true | ||
tuner: | ||
builtinTunerName: TPE | ||
trial: | ||
command: python3 mnist.py --batch_num 200 | ||
codeDir: . | ||
gpuNum: 0 | ||
nasMode: classic_mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
authorName: NNI-example | ||
experimentName: example_mnist | ||
trialConcurrency: 1 | ||
maxExecDuration: 100h | ||
maxTrialNum: 10000 | ||
#choice: local, remote, pai | ||
trainingServicePlatform: local | ||
#choice: true, false | ||
useAnnotation: true | ||
tuner: | ||
#choice: TPE, Random, Anneal, Evolution, BatchTuner, MetisTuner | ||
#SMAC, PPO (SMAC and PPO should be installed through nnictl) | ||
builtinTunerName: PPOTuner | ||
classArgs: | ||
optimize_mode: maximize | ||
trial: | ||
command: python3 mnist.py | ||
codeDir: . | ||
gpuNum: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
authorName: Unknown | ||
experimentName: enas_macro | ||
trialConcurrency: 20 | ||
maxExecDuration: 2400h | ||
maxTrialNum: 20000 | ||
#choice: local, remote | ||
trainingServicePlatform: pai | ||
#choice: true, false | ||
useAnnotation: true | ||
multiPhase: false | ||
versionCheck: false | ||
nniManagerIp: 0.0.0.0 | ||
tuner: | ||
builtinTunerName: PPOTuner | ||
classArgs: | ||
optimize_mode: maximize | ||
trials_per_update: 60 | ||
epochs_per_update: 20 | ||
minibatch_size: 6 | ||
trial: | ||
command: sh ./macro_cifar10_pai.sh | ||
codeDir: ./ | ||
gpuNum: 1 | ||
cpuNum: 1 | ||
memoryMB: 8196 | ||
image: msranni/nni:latest | ||
virtualCluster: nni | ||
paiConfig: | ||
userName: your_account | ||
passWord: your_pwd | ||
host: 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
authorName: Unknown | ||
experimentName: enas_macro | ||
trialConcurrency: 4 | ||
maxExecDuration: 2400h | ||
maxTrialNum: 20000 | ||
#choice: local, remote | ||
trainingServicePlatform: local | ||
#choice: true, false | ||
useAnnotation: true | ||
multiPhase: false | ||
tuner: | ||
builtinTunerName: PPOTuner | ||
classArgs: | ||
optimize_mode: maximize | ||
trials_per_update: 60 | ||
epochs_per_update: 12 | ||
minibatch_size: 10 | ||
trial: | ||
command: sh ./macro_cifar10.sh | ||
codeDir: ./ | ||
gpuNum: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wget https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -e | ||
export PYTHONPATH="$(pwd)" | ||
|
||
python3 src/cifar10/nni_child_cifar10.py \ | ||
--data_format="NCHW" \ | ||
--search_for="macro" \ | ||
--reset_output_dir \ | ||
--data_path="data/cifar10" \ | ||
--output_dir="outputs" \ | ||
--train_data_size=45000 \ | ||
--batch_size=100 \ | ||
--num_epochs=8 \ | ||
--log_every=50 \ | ||
--eval_every_epochs=1 \ | ||
--child_use_aux_heads \ | ||
--child_num_layers=12 \ | ||
--child_out_filters=36 \ | ||
--child_l2_reg=0.0002 \ | ||
--child_num_branches=6 \ | ||
--child_num_cell_layers=5 \ | ||
--child_keep_prob=0.50 \ | ||
--child_drop_path_keep_prob=0.60 \ | ||
--child_lr_cosine \ | ||
--child_lr_max=0.05 \ | ||
--child_lr_min=0.001 \ | ||
--child_lr_T_0=10 \ | ||
--child_lr_T_mul=2 \ | ||
--child_mode="subgraph" \ | ||
"$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -e | ||
export PYTHONPATH="$(pwd)" | ||
|
||
python3 src/cifar10/nni_child_cifar10.py \ | ||
--data_format="NCHW" \ | ||
--search_for="macro" \ | ||
--reset_output_dir \ | ||
--data_path="data/cifar10" \ | ||
--output_dir="outputs" \ | ||
--train_data_size=45000 \ | ||
--batch_size=100 \ | ||
--num_epochs=30 \ | ||
--log_every=50 \ | ||
--eval_every_epochs=1 \ | ||
--child_use_aux_heads \ | ||
--child_num_layers=12 \ | ||
--child_out_filters=36 \ | ||
--child_l2_reg=0.0002 \ | ||
--child_num_branches=6 \ | ||
--child_num_cell_layers=5 \ | ||
--child_keep_prob=0.50 \ | ||
--child_drop_path_keep_prob=0.60 \ | ||
--child_lr_cosine \ | ||
--child_lr_max=0.05 \ | ||
--child_lr_min=0.001 \ | ||
--child_lr_T_0=10 \ | ||
--child_lr_T_mul=2 \ | ||
--child_mode="subgraph" \ | ||
"$@" | ||
|
Empty file.
Empty file.
Oops, something went wrong.