This commit is contained in:
D-X-Y
2019-02-01 01:27:38 +11:00
commit 13e908f4df
104 changed files with 102494 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env sh
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 3 parameters for the GPUs and the epochs and the cutout"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=acc2
cutout=$3
dataset=cifar10
epoch=$2
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.05 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--tau_max 10 --tau_min 4 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the epochs"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=acc2
cutout=0
dataset=cifar10
epoch=$2
SAVED=./snapshots/NAS/ACC-V3-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v3.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.01 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--tau_max 10 --tau_min 1 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

57
scripts-cnn/README.md Normal file
View File

@@ -0,0 +1,57 @@
# Neural-Architecture-Search
### Baseline
```
bash ./scripts-nas/search.sh 1 base cifar10
bash ./scripts-nas/search.sh 1 share
bash ./scripts-nas/batch-base-search.sh 1
bash ./scripts-nas/batch-base-model.sh 1
```
### Meta
```
bash ./scripts-nas/meta-search.sh 0 meta 20 5
```
### Acceleration
```
bash ./scripts-nas/search-acc-v2.sh 3 acc2
bash ./scripts-nas/DMS-V-Train.sh 0
bash ./scripts-nas/search-acc-simple.sh 3 NetworkV2
```
### Base Model Training
```
bash ./scripts-nas/train-model.sh 3 AmoebaNet
bash ./scripts-nas/train-model.sh 3 NASNet
bash ./scripts-nas/train-model.sh 3 DARTS_V1
bash ./scripts-nas/train-model-simple.sh 3 AmoebaNet
bash ./scripts-nas/train-imagenet.sh 3 DARTS_V2 50 14
bash scripts-nas/TRAIN-BASE.sh 0 PNASNet cifar10 nocut 48 11
bash scripts-nas/TRAIN-BASE.sh 0 AmoebaNet cifar10 nocut 36 20
bash scripts-nas/TRAIN-BASE.sh 0 NASNet cifar10 nocut 33 20
bash scripts-nas/TRAIN-BASE.sh 0 DMS_F1 cifar10 nocut 36 20
bash scripts-nas/TRAIN-BASE.sh 0 DMS_V1 cifar10 nocut 36 20
bash scripts-nas/TRAIN-BASE.sh 0 GDAS_CC cifar10 nocut 36 20
bash scripts-nas/train-imagenet.sh 3 DMS_F1 52 14
bash scripts-nas/train-imagenet.sh 3 DMS_V1 50 14
bash scripts-nas/TRAIN-BASE.sh 0 DMS_V1 cifar10 nocut 36 20
```
### Visualization
```
python ./exps-nas/vis-arch.py --checkpoint --save_dir
python ./exps-nas/cvpr-vis.py --save_dir ./snapshots/NAS-VIS/
```
### Test datasets
```
cd ./lib/datasets/
python test_NLP.py
```

30
scripts-cnn/TRAIN-BASE.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env sh
# bash scripts-nas/TRAIN-BASE.sh 0 DMS_V1 cifar10 nocut init-channel layers
if [ "$#" -ne 6 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 6 parameters for the GPUs, the architecture, the dataset, the config, the initial channel, and the number of layers"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
dataset=$3
config=$4
C=$5
N=$6
SAVED=./snapshots/NAS/${arch}-${C}-${N}-${dataset}-${config}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_base.py \
--data_path $TORCH_HOME/cifar.python \
--dataset ${dataset} --arch ${arch} \
--save_path ${SAVED} \
--grad_clip 5 \
--init_channels ${C} --layers ${N} \
--model_config ./configs/nas-cifar-cos-${config}.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env sh
set -e
if [ "$#" -ne 1 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 1 parameters for the GPUs"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
bash ./scripts-nas/train-model.sh ${gpus} AmoebaNet 0
bash ./scripts-nas/train-model.sh ${gpus} NASNet 0
bash ./scripts-nas/train-model.sh ${gpus} DARTS_V1 0
bash ./scripts-nas/train-model.sh ${gpus} DARTS_V2 0

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env sh
if [ "$#" -ne 1 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 1 parameters for the GPUs"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
Times="1 2 3"
for time in ${Times}; do
bash ./scripts-nas/search.sh ${gpus}
done

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env sh
if [ "$#" -ne 4 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 4 parameters for the GPUs and the network and N-way and K-shot"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
n_way=$3
k_shot=$4
cutout=16
epoch=60
SAVED=./snapshots/NAS/Meta-Search-${arch}-N${n_way}-K${k_shot}-cut${cutout}-${epoch}
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/meta_search.py \
--data_path $TORCH_HOME/tiered-imagenet \
--arch ${arch} --n_way ${n_way} --k_shot ${k_shot} \
--save_path ${SAVED} \
--learning_rate_max 0.001 --learning_rate_min 0.0001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos-cut.config \
--print_freq 200 --workers 16

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=100
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E100
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos-simple.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=150
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=200
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=300
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=50
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the network"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=cifar10
epoch=100
SAVED=./snapshots/NAS/ACC-V2-Search-${arch}-${dataset}-cut${cutout}-${epoch}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/acc_search_v2.py \
--data_path $TORCH_HOME/cifar.python \
--arch ${arch} --dataset ${dataset} --batch_size 128 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

45
scripts-cnn/search.sh Normal file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env sh
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 3 parameters for the GPUs and the network and the dataset"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
cutout=0
dataset=$3
epoch=50
SAVED=./snapshots/NAS/Search-${arch}-${dataset}-cut${cutout}-${epoch}
if [ "$dataset" == "cifar10" ] ;then
dataset_root=$TORCH_HOME/cifar.python
print_freq=100
elif [ "$dataset" == "cifar100" ] ;then
dataset_root=$TORCH_HOME/cifar.python
print_freq=100
elif [ "$dataset" == "tiered" ] ;then
dataset_root=$TORCH_HOME/tiered-imagenet
print_freq=500
else
echo 'invalid dataset-name :'${dataset}
exit 1
fi
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_search.py \
--data_path ${dataset_root} \
--arch ${arch} \
--dataset ${dataset} --batch_size 64 \
--save_path ${SAVED} \
--learning_rate_max 0.025 --learning_rate_min 0.001 --momentum 0.9 --weight_decay 0.0003 \
--epochs ${epoch} --cutout ${cutout} --validate --grad_clip 5 \
--init_channels 16 --layers 8 \
--manualSeed 3858 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq ${print_freq} --workers 8

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs, the architecture"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
dataset=cifar100
SAVED=./snapshots/NAS/${arch}-${dataset}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_base.py \
--data_path $TORCH_HOME/cifar.python \
--dataset ${dataset} --arch ${arch} \
--save_path ${SAVED} \
--grad_clip 5 \
--init_channels 36 --layers 20 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env sh
if [ "$#" -ne 4 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 4 parameters for the GPUs, the architecture, and the channel and the layers"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
dataset=imagenet
channels=$3
layers=$4
SAVED=./snapshots/NAS/${arch}-${dataset}-C${channels}-L${layers}-E250
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_base.py \
--data_path $TORCH_HOME/ILSVRC2012 \
--dataset ${dataset} --arch ${arch} \
--save_path ${SAVED} \
--grad_clip 5 \
--init_channels ${channels} --layers ${layers} \
--model_config ./configs/nas-imagenet.config \
--print_freq 200 --workers 20

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs and the architecture"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
dataset=cifar10
SAVED=./snapshots/NAS/${arch}-${dataset}-E100
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_base.py \
--data_path $TORCH_HOME/cifar.python \
--dataset ${dataset} --arch ${arch} \
--save_path ${SAVED} \
--grad_clip 5 \
--model_config ./configs/nas-cifar-cos-simple.config \
--print_freq 100 --workers 8

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for the GPUs, the architecture"
exit 1
fi
if [ "$TORCH_HOME" = "" ]; then
echo "Must set TORCH_HOME envoriment variable for data dir saving"
exit 1
else
echo "TORCH_HOME : $TORCH_HOME"
fi
gpus=$1
arch=$2
dataset=cifar10
SAVED=./snapshots/NAS/${arch}-${dataset}-E600
CUDA_VISIBLE_DEVICES=${gpus} python ./exps-nas/train_base.py \
--data_path $TORCH_HOME/cifar.python \
--dataset ${dataset} --arch ${arch} \
--save_path ${SAVED} \
--grad_clip 5 \
--init_channels 36 --layers 20 \
--model_config ./configs/nas-cifar-cos.config \
--print_freq 100 --workers 8

9
scripts-cnn/vis.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
seeds="seed-8167 seed-908 seed-9242"
for seed in ${seeds}; do
python ./exps-nas/vis-arch.py --checkpoint ./snapshots/NAS/Search-cifar10-cut16-100/${seed}/checkpoint-search.pth \
--save_dir ./snapshots/NAS-VIS/Search-cut16-100/${seed}
done