forked from tatz1101/Edge-AI-Platform-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpruning_flow.sh
More file actions
68 lines (51 loc) · 3.87 KB
/
pruning_flow.sh
File metadata and controls
68 lines (51 loc) · 3.87 KB
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
68
#!/bin/sh
ML_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && cd ../../.. && pwd )"
export ML_DIR
PRUNE_ROOT=/usr/local/bin
WORK_DIR=$ML_DIR/deephi/alexnetBNnoLRN/pruning
[ -f /usr/local/bin/deephi_compress ] || PRUNE_ROOT=$HOME/ML/DNNDK/tools
#take the caffemodel with a soft link to save HD space
ln -nsf $ML_DIR/caffe/models/alexnetBNnoLRN/m2/snapshot_2_alexnetBNnoLRN__iter_12000.caffemodel ${WORK_DIR}/float.caffemodel
#ln -nsf $HOME/ML/cats-vs-dogs/caffe/models/alexnetBNnoLRN/m2/rpt/aws_float.caffemodel ${WORK_DIR}/float.caffemodel
# analysis: you do it only once
$PRUNE_ROOT/deephi_compress ana -config ${WORK_DIR}/config0.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_ana_alexnetBNnoLRN.txt
# compression: zero run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config0.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress0_alexnetBNnoLRN.txt
# fine-tuning: zero run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config0.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune0_alexnetBNnoLRN.txt
# compression: first run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config1.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress1_alexnetBNnoLRN.txt
# fine-tuning: first run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config1.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune1_alexnetBNnoLRN.txt
# compression: second run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config2.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress2_alexnetBNnoLRN.txt
## fine-tuning: second run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config2.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune2_alexnetBNnoLRN.txt
## compression: third run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config3.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress3_alexnetBNnoLRN.txt
## fine-tuning: third run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config3.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune3_alexnetBNnoLRN.txt
## compression: fourth run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config4.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress4_alexnetBNnoLRN.txt
## fine-tuning: fourth run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config4.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune4_alexnetBNnoLRN.txt
## compression: fift run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config5.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress5_alexnetBNnoLRN.txt
## fine-tuning: fift run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config5.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune5_alexnetBNnoLRN.txt
## compression: 6-th run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config6.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress6_alexnetBNnoLRN.txt
## fine-tuning: 6-th run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config6.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune6_alexnetBNnoLRN.txt
## compression: 7-th run
$PRUNE_ROOT/deephi_compress compress -config ${WORK_DIR}/config7.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_compress7_alexnetBNnoLRN.txt
## fine-tuning: 7-th run
$PRUNE_ROOT/deephi_compress finetune -config ${WORK_DIR}/config7.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_finetune7_alexnetBNnoLRN.txt
## last step: get the final output model
## note that it does not work if you used the "final.prototxt" as wrongly described by transform help
$PRUNE_ROOT/deephi_compress transform -model ${WORK_DIR}/train_val.prototxt -weights ${WORK_DIR}/regular_rate_0.7/sparse.caffemodel 2>&1 | tee ${WORK_DIR}/rpt/logfile_transform_alexnetBNnoLRN.txt
# get flops and the number of parameters of a model
#$PRUNE_ROOT/deephi_compress stat -model ${WORK_DIR}/train_val.prototxt 2>&1 | tee ${WORK_DIR}/rpt/logfile_stat_alexnetBNnoLRN.txt
for file in $(find $ML_DIR -name transformed.caffemodel); do
mv ${file} ${WORK_DIR}
done