-
Notifications
You must be signed in to change notification settings - Fork 5
/
train.sh
119 lines (104 loc) · 5.37 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
#!/bin/bash
while getopts 'e:c:i:l:w:t:n:d:' OPT; do
case $OPT in
e) exp=$OPTARG;;
c) cuda=$OPTARG;;
i) identifier=$OPTARG;;
l) lr=$OPTARG;;
w) stu_w=$OPTARG;;
t) task=$OPTARG;;
n) num_epochs=$OPTARG;;
d) train_flag=$OPTARG;;
esac
done
echo "exp:" $exp
echo "cuda:" $cuda
echo "num_epochs:" $num_epochs
echo "train_flag:" $train_flag
if [[ "${task}" == *"la"* ]];
then
label_ratio=$(echo "${task}" | cut -d'_' -f2)
labeled_data="labeled_"${label_ratio}
unlabeled_data="unlabeled_"${label_ratio}
eval_data="eval_"${label_ratio}
test_data="test"
folder="Exp_SSL_LA_"${label_ratio}"/"
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold1 --seed 0 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate_la.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} -t ${task}
fi
if [[ "${task}" == *"synapse"* ]];
then
label_ratio=$(echo "${task}" | cut -d'_' -f2)
labeled_data="labeled_"${label_ratio}
unlabeled_data="unlabeled_"${label_ratio}
eval_data="eval"
test_data="test"
folder="Exp_IBSSL_Synapse_"${label_ratio}"/"
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold1 --seed 0 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} -t ${task}
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold2 --seed 1 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold2 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 2 --split ${test_data} -t ${task}
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold3 --seed 666 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold3 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 3 --split ${test_data} -t ${task}
fi
if [ ${task} = "mmwhs_ct2mr" ];
then
labeled_data="train_ct2mr_labeled"
unlabeled_data="train_ct2mr_unlabeled"
eval_data="eval_ct2mr"
test_data="test_mr"
modality="MR"
folder="Exp_UDA_MMWHS_ct2mr/"
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold1 --seed 0 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} --modality ${modality} -t ${task}
fi
if [ ${task} = "mmwhs_mr2ct" ];
then
labeled_data="train_mr2ct_labeled"
unlabeled_data="train_mr2ct_unlabeled"
eval_data="eval_mr2ct"
test_data="test_ct"
modality="CT"
folder="Exp_UDA_MMWHS_mr2ct/"
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold1 --seed 0 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task}
fi
python code/test.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} --modality ${modality} -t ${task}
fi
if [[ "${task}" == *"mnms"* ]];
then
domain=$(echo "${task}" | cut -d'_' -f2)
label_ratio=$(echo "${task}" | cut -d'_' -f3)
labeled_data="train_to${domain}_labeled_"${label_ratio}
unlabeled_data="train_to${domain}_unlabeled_"${label_ratio}
eval_data="test_to${domain}_"${label_ratio}
test_data="test_to${domain}_"${label_ratio}
folder="Exp_SemiDG_MNMs_to${domain}_"${label_ratio}"/"
echo "cur_folder:" $folder
if [ ${train_flag} = "true" ]; then
python code/train_${exp}.py --exp ${folder}${exp}${identifier}/fold1 --seed 0 -g ${cuda} --base_lr ${lr} -w ${stu_w} -ep ${num_epochs} -sl ${labeled_data} -su ${unlabeled_data} -se ${eval_data} -t ${task} -cr 100
fi
if [[ "${exp}" == *"2d"* ]]; then
python code/test_2d.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate_2d.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} -t ${task}
else
python code/test.py --exp ${folder}${exp}${identifier}/fold1 -g ${cuda} --split ${test_data} -t ${task}
python code/evaluate.py --exp ${folder}${exp}${identifier} --folds 1 --split ${test_data} -t ${task}
fi
fi