-
Notifications
You must be signed in to change notification settings - Fork 20
/
train.sh
141 lines (125 loc) · 2.88 KB
/
train.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# python PATH
# export PYTHONPATH="${PYTHONPATH}:${HOME}/github"
# hyperparameter
echo -n "input the gpu (seperate by comma (,) ): "
read gpus
export CUDA_VISIBLE_DEVICES=${gpus}
echo "using gpus ${gpus}"
# replace comma(,) with empty
#gpus=${gpus//,/}
# the number of characters
#num_gpus=${#gpus}
#echo "the number of gpus is ${num_gpus}"
# choose the method
echo ""
echo "0 -- DANN"
echo "1 -- ALDA"
echo -n "choose the method: "
read method_choose
case ${method_choose} in
0 )
method="DANN"
;;
1 )
method="ALDA_hard"
;;
* )
echo "The choice of method is illegal!"
exit 1
;;
esac
# choose the loss_type
echo ""
echo "all -- ALDA with full losses"
echo "nocorrect -- ALDA without the target loss"
echo -n "choose the loss_type: "
read loss_type
# choose the threshold
echo ""
echo "0.9 -- the optimum for office"
echo -n "choose the threshold: "
read threshold
echo ""
echo "0 -- default"
echo -n "run_id: "
read run_id
echo "${method}=${trade_off}_loss_type=${loss_type}_thresh=${threshold}_${run_id}"
for num in 01 02 03 04 05 06
do
case ${num} in
01 )
s_dset_path="./data/office/amazon_list.txt"
t_dset_path="./data/office/webcam_list.txt"
output_dir="A2W"
;;
02 )
s_dset_path="./data/office/webcam_list.txt"
t_dset_path="./data/office/amazon_list.txt"
output_dir="W2A"
;;
03 )
s_dset_path="./data/office/amazon_list.txt"
t_dset_path="./data/office/dslr_list.txt"
output_dir="A2D"
;;
04 )
s_dset_path="./data/office/dslr_list.txt"
t_dset_path="./data/office/amazon_list.txt"
output_dir="D2A"
;;
05 )
s_dset_path="./data/office/dslr_list.txt"
t_dset_path="./data/office/webcam_list.txt"
output_dir="D2W"
;;
06 )
s_dset_path="./data/office/webcam_list.txt"
t_dset_path="./data/office/dslr_list.txt"
output_dir="W2D"
;;
esac
# create PID
output_dir="${output_dir}_${method}"
final_log="${method}"
case ${loss_type} in
0 )
output_dir="${output_dir}"
;;
* )
output_dir="${output_dir}=${loss_type}"
final_log="${final_log}=${loss_type}"
;;
esac
output_dir="${output_dir}_thresh=${threshold}"
final_log="${final_log}_thresh=${threshold}"
case ${run_id} in
0 )
output_dir="${output_dir}"
;;
* )
output_dir="${output_dir}_${run_id}"
final_log="${final_log}_${run_id}"
;;
esac
echo "Begin in ${output_dir}"
echo "log in ${final_log}_log.txt"
# train the model
python train.py ${method} \
--gpu_id ${gpus} \
--net ResNet50 \
--dset office \
--test_interval 500 \
--s_dset_path ${s_dset_path} \
--t_dset_path ${t_dset_path} \
--trade_off 1 \
--batch_size 36 \
--output_dir ${output_dir} \
--final_log "${final_log}_log.txt" \
--loss_type ${loss_type} \
--threshold ${threshold} \
--cos_dist False \
--source_detach False
echo "Finish in ${output_dir}"
done
echo "Training Finished!!!"