-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathone-shot-finetune.sh
58 lines (48 loc) · 1.63 KB
/
one-shot-finetune.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
#!/bin/bash
nvidia-smi
latencyratio=-1
wd=1e-4
optim=sgd
lr=0.001
lrdecayeach=10
ratio=1.0 #Ratio of used dataset
dataset=CIFAR100
resnet56(){
model=resnet
depth=56
loadmodel=$dataset'-baseline/'$model'50/model_best.pth.tar'
pruningconfig='./configs/cifar_resnet50.json'
}
resnet56
export CUDA_VISIBLE_DEVICES=0
echo 'Filter pruning ...'
for method in 0 2 6 22 30
do
root=$dataset'/'$model'50/one_shot_criterion'$method
dir=$root'/filterpruning'
echo "Checkpoint director: " $dir
python main.py --name=$dir --dataset=$dataset \
--lr=$lr --lr-decay-every=$lrdecayeach --momentum=0.9 --epochs=30 --batch-size=128 \
--pruning=True --seed=0 --model=$model'50' \
--mgpu=False --group_wd_coeff=1e-8 --wd=$wd --tensorboard=True --pruning-method=$method \
--data=${datasetdir} --no_grad_clip=True --pruning_config=$pruningconfig \
--only-estimate-latency=True \
--data=${datasetdir} --ratio $ratio --prune-latency-ratio $latencyratio \
--load_model $loadmodel
done
for nr in 1 2
do
echo 'Block pruning ... '$nr
for method in 0 2 6 22 30
do
root=$dataset'/'$model'50/one_shot_criterion'$method
crit=$root'/criteria_'$method'_importance.pickle'
dir=$root'/finetune'-$nr
echo "Checkpoint director: " $dir
python finetune.py --dataset $dataset --arch $model --depth $depth --save $dir --remove $nr --criterion $crit \
--lr=$lr --lr-decay-every=$lrdecayeach --momentum=0.9 --epochs=30 --batch-size=128 \
--load-model $loadmodel
done
done
echo 'Generate results table ...'
python generate-table.py $dataset'/'$model'50/'