Our project is based on AutoML Framework hyperbox
, so you need to first install hyperbox
.
There are two ways to install hyperbox:
- install via pip
pip install hyperbox
- install via git (recommended)
git clone https://github.com/marsggbo/hyperbox
cd hyperbox
python setup.py develop
python install -r requirements.txt
pip install pytorch-lightning==1.5.8 # higher version are not tested
git clone https://github.com/marsggbo/NAS-LID
cd hyperbox_app
python setup.py develop
pip install -r requirements.txt
hyperbox_app/hyperbox_app/distributed/Imagenet_train
: finetune the final searched models on the ImageNet. Please seehyperbox_app/hyperbox_app/distributed/Imagenet_train/scripts
for details of finetuning.- The other folders and files in
hyperbox_app/hyperbox_app/distributed
are used for Supernet Partition and Evolution-based Search. - All configurations are managed by
hydra
library, you can read or modify them inhyperbox_app/hyperbox_app/distributed/configs
. An experiment needs to specify multiple modules, such asdatamodule
,engine
,model
,trainer
, andlogger
. Specifically, the yaml files inhyperbox_app/hyperbox_app/distributed/configs/experiment
integrate all above modules. For example,hyperbox_app/hyperbox_app/distributed/configs/experiment/fewshot_search_nb201.yaml
is used for experiment of splitting NB201 search space. You can create you own yaml file to run a different experiment.
Splitting NAS-Bench-201
bash ./scripts/fewshot/fewshot_search_nb201.sh 0 nb201_c10_ID_mincut_sp_16splits \
"logger.wandb.offline=True trainer.strategy=null engine.split_criterion=ID engine.split_method=mincut"
nb201_c10_ID_mincut_sp_16splits
is the experiment name, which is used for creating experiment log folder.- replacing
engine.split_criterion=ID
byengine.split_criterion=grad
will split the Supernet via gradient.
bash ./scripts/fewshot/fewshot_search_nb201.sh 4 nb201_c10_ID_mincut_sp_16splits \
"logger.wandb.offline=True trainer.strategy=null engine.split_criterion=ID engine.split_method=mincut +trainer.strategy=ddp"
bash ./scripts/fewshot/fewshot_search_nb201.sh 0 debug_nb201_c10_ID_mincut_sp_4splits \
"ipdb_debug=False logger.wandb.offline=True trainer.strategy=null +trainer.limit_val_batches=10 engine.split_criterion=ID engine.split_method=mincut engine.is_single_path=True +trainer.fast_dev_run=True engine.warmup_epochs=[1,2] engine.repeat_num=1 engine.finetune_epoch=1"
Simialrly, the following line can generate a series of running commands for evolution-based search.
The following two paths are important:
-
- the configuration template of ea-based search, e.g.,
/path/to/scripts/fewshot/ea_search_cfgs
(absolute path is preferred)
- the configuration template of ea-based search, e.g.,
-
- the log path of the previous experiment in Step 3, e.g.,
/path/to/logs/runs/nb201_c10_ID_mincut_sp_16splits/2022-12-10_07-50-42
- the log path of the previous experiment in Step 3, e.g.,
path1=/path/to/scripts/fewshot/ea_search_cfgs
path2=/path/to/logs/runs/nb201_c10_ID_mincut_sp_16splits/2022-12-10_07-50-42
bash scripts/fewshot/ea_search.sh [0] eaSearch_exp_name 1.0 ${path1} " ++engine.supernet_mask_path_pattern=${path2}/checkpoints/*mask.json ipdb_debug=False trainer.fast_dev_run=False model.mutator_cfg.evolution_epochs=100 model.mutator_cfg.population_num=50"
- Command for debug
path1=/path/to/scripts/fewshot/ea_search_cfgs
path2=/path/to/logs/runs/nb201_c10_ID_mincut_sp_16splits/2022-12-10_07-50-42
bash scripts/fewshot/ea_search.sh [0] eaSearch_exp_name 1.0 ${path1} " ++engine.supernet_mask_path_pattern=${path2}/checkpoints/*mask.json ipdb_debug=True trainer.fast_dev_run=True model.mutator_cfg.evolution_epochs=2 model.mutator_cfg.population_num=10"
The way of reproducing the results on OFA and ProxylessNAS search space is detailed in the following folder
cd hyperbox_app/hyperbox_app/distributed/Imagenet_train/scripts
You may need to modify the path arguments to your local path in each bash scripts before evaluations.