-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_oneshot.sh
67 lines (65 loc) · 1.75 KB
/
run_oneshot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# shellcheck disable=SC2120
function run_proxylessnas() {
model=$1
lossType=$2
wid=$3
count=$5
batch=$6
echo start "${model}" "${lossType}" "$wid" "${count}"
dir=./checkpoints/replace/"${model}"/"${count}"/"${lossType}"
# search
mkdir -p "${dir}"
python main.py \
--net "${model}" \
--dataset imagenet \
--data_path ~/data/ \
--grad_reg_loss_type "${lossType}" \
--worker_id "$wid" \
--pretrained \
--epochs 50 \
--train_batch_size "${batch}" \
--expect_latency_rate "${count}" \
--checkpoint_path "${dir}"/arch_path.pt \
--exported_arch_path "${dir}"/checkpoint2.json \
--train_mode "$4" \
--kd_teacher_path ~/projects/nonlinearNAS/checkpoints/teacher/d2_224_85.2.pth.tar
}
function run_spatial() {
model=$1
lossType=$2
wid=$3
count=$5
batch=$6
echo start "${model}" "${lossType}" "$wid" "${count}"
dir=./checkpoints/replace/"${model}"/"${count}"/"${lossType}"
# search
mkdir -p "${dir}"
python main.py \
--net "${model}" \
--dataset imagenet \
--data_path ~/data/ \
--grad_reg_loss_type "${lossType}" \
--worker_id "$wid" \
--pretrained \
--epochs 50 \
--train_batch_size "${batch}" \
--expect_latency_rate "${count}" \
--checkpoint_path "${dir}"/arch_path.pt \
--exported_arch_path "${dir}"/checkpoint2.json \
--train_mode "$4" \
--spatial \
--kd_teacher_path ~/projects/nonlinearNAS/checkpoints/teacher/d2_224_85.2.pth.tar
}
# Parse script arguments
for arg in "$@"
do
if [ "$arg" == "--spatial" ]
then
# Run run_spatial if --spatial is among the arguments
run_spatial "$1" add#linear 0,1,2,3,4,5,6,7 "$2" "$3" "$4"
exit 0
fi
done
# Run run_proxylessnas if --spatial is not among the arguments
run_proxylessnas "$1" add#linear 0 "$2" "$3" "$4"