add autodl

This commit is contained in:
mhz
2024-08-25 18:02:31 +02:00
parent 192f286cfb
commit a0a25f291c
431 changed files with 50646 additions and 8 deletions

View File

@@ -0,0 +1,52 @@
#!/bin/bash
##############################################################################
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size #
##############################################################################
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.01 #
##############################################################################
# CUDA_VISIBLE_DEVICES=0 bash scripts/NATS-Bench/train-shapes.sh 00000-05000 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 05001-10000 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 10001-14500 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 14501-18000 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 18001-19500 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 19501-23500 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 23501-27500 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 27501-30000 12 777
# bash ./scripts/NATS-Bench/train-shapes.sh 30001-32767 12 777
#
# CUDA_VISIBLE_DEVICES=2 bash ./scripts/NATS-Bench/train-shapes.sh 01000-03999,04050-05000,06000-09000,11000-14500,15000-18500,20000-23500,25000-27500,29000-30000 12 777
# SLURM_PROCID=1 SLURM_NTASKS=5 bash ./scripts/NATS-Bench/train-shapes.sh 01000-03999,04050-05000,06000-09000,11000-14500,15000-18500,20000-23500,25000-27500,29000-30000 90 777
# [GCP] bash ./scripts/NATS-Bench/train-shapes.sh 00000-09999 90 777
# [UTS] bash ./scripts/NATS-Bench/train-shapes.sh 30000-32767 90 777
##############################################################################
echo script name: $0
echo $# arguments
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 3 parameters for start-and-end, hyper-parameters-opt-file, and seeds"
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
srange=$1
opt=$2
all_seeds=$3
cpus=4
save_dir=./output/NATS-Bench-size/
OMP_NUM_THREADS=${cpus} python exps/NATS-Bench/main-sss.py \
--mode new --srange ${srange} --hyper ${opt} --save_dir ${save_dir} \
--datasets cifar10 cifar10 cifar100 ImageNet16-120 \
--splits 1 0 0 0 \
--xpaths $TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python/ImageNet16 \
--workers ${cpus} \
--seeds ${all_seeds}

View File

@@ -0,0 +1,48 @@
#!/bin/bash
##############################################################################
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size #
##############################################################################
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.01 #
##############################################################################
# [saturn1] CUDA_VISIBLE_DEVICES=0 bash scripts/NATS-Bench/train-topology.sh 00000-02000 200 "777 888 999"
# [saturn1] CUDA_VISIBLE_DEVICES=0 bash scripts/NATS-Bench/train-topology.sh 02000-04000 200 "777 888 999"
# [saturn1] CUDA_VISIBLE_DEVICES=1 bash scripts/NATS-Bench/train-topology.sh 04000-06000 200 "777 888 999"
# [saturn1] CUDA_VISIBLE_DEVICES=1 bash scripts/NATS-Bench/train-topology.sh 06000-08000 200 "777 888 999"
#
# CUDA_VISIBLE_DEVICES=0 bash scripts/NATS-Bench/train-topology.sh 00000-05000 12 777
# bash ./scripts/NATS-Bench/train-topology.sh 05001-10000 12 777
# bash ./scripts/NATS-Bench/train-topology.sh 10001-14500 12 777
# bash ./scripts/NATS-Bench/train-topology.sh 14501-15624 12 777
#
##############################################################################
echo script name: $0
echo $# arguments
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 3 parameters for start-and-end, hyper-parameters-opt-file, and seeds"
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
srange=$1
opt=$2
all_seeds=$3
cpus=4
save_dir=./output/NATS-Bench-topology/
OMP_NUM_THREADS=${cpus} python exps/NATS-Bench/main-tss.py \
--mode new --srange ${srange} --hyper ${opt} --save_dir ${save_dir} \
--datasets cifar10 cifar10 cifar100 ImageNet16-120 \
--splits 1 0 0 0 \
--xpaths $TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python \
$TORCH_HOME/cifar.python/ImageNet16 \
--workers ${cpus} \
--seeds ${all_seeds}

View File

@@ -0,0 +1,13 @@
#!/bin/bash
# bash ./scripts/TAS/prepare.sh
#datasets='cifar10 cifar100 imagenet-1k'
#ratios='0.5 0.8 0.9'
ratios='0.5'
save_dir=./.latent-data/splits
for ratio in ${ratios}
do
python ./exps/TAS/prepare.py --name cifar10 --root $TORCH_HOME/cifar.python --save ${save_dir}/cifar10-${ratio}.pth --ratio ${ratio}
python ./exps/TAS/prepare.py --name cifar100 --root $TORCH_HOME/cifar.python --save ${save_dir}/cifar100-${ratio}.pth --ratio ${ratio}
python ./exps/TAS/prepare.py --name imagenet-1k --root $TORCH_HOME/ILSVRC2012 --save ${save_dir}/imagenet-1k-${ratio}.pth --ratio ${ratio}
done

View File

@@ -0,0 +1,37 @@
#!/bin/bash
# bash ./scripts/base-train.sh cifar10 ResNet110 E300 L1 256 -1
echo script name: $0
echo $# arguments
if [ "$#" -ne 6 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 6 parameters for the dataset and the-model-name and epochs and LR and the-batch-size and the-random-seed"
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
dataset=$1
model=$2
epoch=$3
LR=$4
batch=$5
rseed=$6
save_dir=./output/basic/${dataset}/${model}-${epoch}-${LR}-${batch}
python --version
OMP_NUM_THREADS=4 python ./exps/basic/basic-main.py --dataset ${dataset} \
--data_path $TORCH_HOME/cifar.python \
--model_config ./configs/archs/CIFAR-${model}.config \
--optim_config ./configs/opts/CIFAR-${epoch}-W5-${LR}-COS.config \
--procedure basic \
--save_dir ${save_dir} \
--cutout_length -1 \
--batch_size ${batch} --rand_seed ${rseed} --workers 4 \
--eval_frequency 1 --print_freq 100 --print_freq_eval 200

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# bash ./scripts/black.sh
# script=$(readlink -f "$0")
# scriptpath=$(dirname "$script")
# echo $scriptpath
# delete Python cache files
find . | grep -E "(__pycache__|\.pyc|\.DS_Store|\.pyo$)" | xargs rm -rf
black ./tests/
black ./xautodl/procedures
black ./xautodl/datasets
black ./xautodl/xlayers
black ./exps/trading
rm -rf ./xautodl.egg-info
rm -rf ./build
rm -rf ./dist
rm -rf ./.pytest_cache

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# bash ./scripts/experimental/train-vit.sh cifar10 -1
echo script name: $0
echo $# arguments
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 2 parameters for dataset and random-seed"
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
dataset=$1
rseed=$2
save_dir=./outputs/${dataset}/vit-experimental
python --version
python ./exps/basic/xmain.py --save_dir ${save_dir} --rand_seed ${rseed} \
--train_data_config ./configs/yaml.data/${dataset}.train \
--valid_data_config ./configs/yaml.data/${dataset}.test \
--data_path $TORCH_HOME/cifar.python \
--model_config ./configs/yaml.model/vit-cifar10.s0 \
--optim_config ./configs/yaml.opt/vit.cifar \
--loss_config ./configs/yaml.loss/cross-entropy \
--metric_config ./configs/yaml.loss/top-ce \
--batch_size 256 \
--lr 0.003 --weight_decay 0.3 --scheduler warm-cos --steps 10000

View File

@@ -0,0 +1,51 @@
#!/bin/bash
# bash ./scripts/nas-infer-train.sh cifar10 SETN 256 -1
echo script name: $0
echo $# arguments
if [ "$#" -ne 4 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 4 parameters for dataset, the-model-name, the-batch-size and the-random-seed"
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
dataset=$1
model=$2
batch=$3
rseed=$4
if [ ${dataset} == 'cifar10' ] || [ ${dataset} == 'cifar100' ]; then
xpath=$TORCH_HOME/cifar.python
base=CIFAR
workers=4
cutout_length=16
elif [ ${dataset} == 'imagenet-1k' ]; then
xpath=$TORCH_HOME/ILSVRC2012
base=IMAGENET
workers=28
cutout_length=-1
else
exit 1
echo 'Unknown dataset: '${dataset}
fi
SAVE_ROOT="./output"
save_dir=${SAVE_ROOT}/nas-infer/${dataset}-${model}-${batch}
python --version
python ./exps/basic/basic-main.py --dataset ${dataset} \
--data_path ${xpath} --model_source nas \
--model_config ./configs/archs/NAS-${base}-${model}.config \
--optim_config ./configs/opts/NAS-${base}.config \
--procedure basic \
--save_dir ${save_dir} \
--cutout_length ${cutout_length} \
--batch_size ${batch} --rand_seed ${rseed} --workers ${workers} \
--eval_frequency 1 --print_freq 500 --print_freq_eval 1000

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# bash ./scripts/retrain-searched-net.sh cifar10 ${NAME} ${PATH} 256 -1
echo script name: $0
echo $# arguments
if [ "$#" -ne 5 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 5 parameters for dataset, the save dir base name, the model path, the batch size, the random seed"
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
dataset=$1
save_name=$2
model_path=$3
batch=$4
rseed=$5
if [ ${dataset} == 'cifar10' ] || [ ${dataset} == 'cifar100' ]; then
xpath=$TORCH_HOME/cifar.python
base=CIFAR
workers=4
cutout_length=16
elif [ ${dataset} == 'imagenet-1k' ]; then
xpath=$TORCH_HOME/ILSVRC2012
base=IMAGENET
workers=28
cutout_length=-1
else
exit 1
echo 'Unknown dataset: '${dataset}
fi
SAVE_ROOT="./output"
save_dir=${SAVE_ROOT}/nas-infer/${dataset}-BS${batch}-${save_name}
python --version
python ./exps/basic/basic-main.py --dataset ${dataset} \
--data_path ${xpath} --model_source autodl-searched \
--model_config ./configs/archs/NAS-${base}-none.config \
--optim_config ./configs/opts/NAS-${base}.config \
--extra_model_path ${model_path} \
--procedure basic \
--save_dir ${save_dir} \
--cutout_length ${cutout_length} \
--batch_size ${batch} --rand_seed ${rseed} --workers ${workers} \
--eval_frequency 1 --print_freq 500 --print_freq_eval 1000

View File

@@ -0,0 +1,65 @@
#!/bin/bash
# bash ./scripts/tas-infer-train.sh cifar10 C100-ResNet32 -1
set -e
echo script name: $0
echo $# arguments
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
echo "Need 3 parameters for the dataset and the-config-name and the-random-seed"
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
dataset=$1
model=$2
rseed=$3
batch=256
save_dir=./output/search-shape/TAS-INFER-${dataset}-${model}
if [ ${dataset} == 'cifar10' ] || [ ${dataset} == 'cifar100' ]; then
xpath=$TORCH_HOME/cifar.python
opt_config=./configs/opts/CIFAR-E300-W5-L1-COS.config
workers=4
elif [ ${dataset} == 'imagenet-1k' ]; then
xpath=$TORCH_HOME/ILSVRC2012
#opt_config=./configs/opts/ImageNet-E120-Cos-Smooth.config
opt_config=./configs/opts/RImageNet-E120-Cos-Soft.config
workers=28
else
echo 'Unknown dataset: '${dataset}
exit 1
fi
python --version
# normal training
xsave_dir=${save_dir}-NMT
OMP_NUM_THREADS=4 python ./exps/basic/basic-main.py --dataset ${dataset} \
--data_path ${xpath} \
--model_config ./configs/NeurIPS-2019/${model}.config \
--optim_config ${opt_config} \
--procedure basic \
--save_dir ${xsave_dir} \
--cutout_length -1 \
--batch_size ${batch} --rand_seed ${rseed} --workers ${workers} \
--eval_frequency 1 --print_freq 100 --print_freq_eval 200
# KD training
xsave_dir=${save_dir}-KDT
OMP_NUM_THREADS=4 python ./exps/basic/KD-main.py --dataset ${dataset} \
--data_path ${xpath} \
--model_config ./configs/NeurIPS-2019/${model}.config \
--optim_config ${opt_config} \
--KD_checkpoint ./.latent-data/basemodels/${dataset}/${model}.pth \
--procedure Simple-KD \
--save_dir ${xsave_dir} \
--KD_alpha 0.9 --KD_temperature 4 \
--cutout_length -1 \
--batch_size ${batch} --rand_seed ${rseed} --workers ${workers} \
--eval_frequency 1 --print_freq 100 --print_freq_eval 200

View File

@@ -0,0 +1,25 @@
#!/bin/bash
#
# bash scripts/trade/baseline.sh 0 csi300
# bash scripts/trade/baseline.sh 1 csi100
# bash scripts/trade/baseline.sh 1 all
#
set -e
echo script name: $0
echo $# arguments
if [ "$#" -ne 2 ] ;then
echo "Input illegal number of parameters " $#
exit 1
fi
gpu=$1
market=$2
# algorithms="NAIVE-V1 NAIVE-V2 MLP GRU LSTM ALSTM XGBoost LightGBM SFM TabNet DoubleE"
algorithms="XGBoost LightGBM SFM TabNet DoubleE"
for alg in ${algorithms}
do
python exps/trading/baselines.py --alg ${alg} --gpu ${gpu} --market ${market}
done

View File

@@ -0,0 +1,34 @@
#!/bin/bash
#
# bash scripts/trade/tsf-all.sh 0 csi300 0_0
# bash scripts/trade/tsf-all.sh 0 csi300 0.1_0
# bash scripts/trade/tsf-all.sh 1 all
#
set -e
echo script name: $0
echo $# arguments
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
exit 1
fi
gpu=$1
market=$2
drop=$3
channels="6 12 24 32 48 64"
#depths="1 2 3 4 5 6 7 8"
for channel in ${channels}
do
python exps/trading/baselines.py --alg TSF-1x${channel}-drop${drop} \
TSF-2x${channel}-drop${drop} \
TSF-3x${channel}-drop${drop} \
TSF-4x${channel}-drop${drop} \
TSF-5x${channel}-drop${drop} \
TSF-6x${channel}-drop${drop} \
TSF-7x${channel}-drop${drop} \
TSF-8x${channel}-drop${drop} \
--gpu ${gpu} --market ${market} --shared_dataset True
done

View File

@@ -0,0 +1,26 @@
#!/bin/bash
#
# bash scripts/trade/tsf-time.sh 0 csi300 TSF-2x24-drop0_0
# bash scripts/trade/tsf-time.sh 1 csi100
# bash scripts/trade/tsf-time.sh 1 all
#
set -e
echo script name: $0
echo $# arguments
if [ "$#" -ne 3 ] ;then
echo "Input illegal number of parameters " $#
exit 1
fi
gpu=$1
market=$2
base=$3
xtimes="2008-01-01 2008-07-01 2009-01-01 2009-07-01 2010-01-01 2011-01-01 2012-01-01 2013-01-01"
for xtime in ${xtimes}
do
python exps/trading/baselines.py --alg ${base}s${xtime} --gpu ${gpu} --market ${market} --shared_dataset False
done

View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# bash scripts/trade/tsf.sh 0 csi300 3 0_0
# bash scripts/trade/tsf.sh 0 csi300 3 0.1_0
# bash scripts/trade/tsf.sh 1 csi100 3 0.2_0
# bash scripts/trade/tsf.sh 1 all 3 0.1_0
#
set -e
echo script name: $0
echo $# arguments
if [ "$#" -ne 4 ] ;then
echo "Input illegal number of parameters " $#
exit 1
fi
gpu=$1
market=$2
depth=$3
drop=$4
channels="6 12 24 32 48 64"
for channel in ${channels}
do
python exps/trading/baselines.py --alg TSF-${depth}x${channel}-drop${drop} --gpu ${gpu} --market ${market}
done