-
Notifications
You must be signed in to change notification settings - Fork 26
/
run_classifier.sh
142 lines (135 loc) · 3.41 KB
/
run_classifier.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
142
for i in "$@"
do
case $i in
-g=*|--gpudevice=*)
GPUDEVICE="${i#*=}"
shift
;;
-n=*|--numgpus=*)
NUMGPUS="${i#*=}"
shift
;;
-t=*|--taskname=*)
TASKNAME="${i#*=}"
shift
;;
-r=*|--randomseed=*)
RANDOMSEED="${i#*=}"
shift
;;
-p=*|--predicttag=*)
PREDICTTAG="${i#*=}"
shift
;;
-m=*|--modeldir=*)
MODELDIR="${i#*=}"
shift
;;
-d=*|--datadir=*)
DATADIR="${i#*=}"
shift
;;
-o=*|--outputdir=*)
OUTPUTDIR="${i#*=}"
shift
;;
--maxlen=*)
MAXLEN="${i#*=}"
shift
;;
--batchsize=*)
BATCHSIZE="${i#*=}"
shift
;;
--learningrate=*)
LEARNINGRATE="${i#*=}"
shift
;;
--trainsteps=*)
TRAINSTEPS="${i#*=}"
shift
;;
--warmupsteps=*)
WARMUPSTEPS="${i#*=}"
shift
;;
--savesteps=*)
SAVESTEPS="${i#*=}"
shift
;;
esac
done
echo "gpu device = ${GPUDEVICE}"
echo "num gpus = ${NUMGPUS}"
echo "task name = ${TASKNAME}"
echo "random seed = ${RANDOMSEED}"
echo "predict tag = ${PREDICTTAG}"
echo "model dir = ${MODELDIR}"
echo "data dir = ${DATADIR}"
echo "output dir = ${OUTPUTDIR}"
echo "max len = ${MAXLEN}"
echo "batch size = ${BATCHSIZE}"
echo "learning rate = ${LEARNINGRATE}"
echo "train steps = ${TRAINSTEPS}"
echo "warmup steps = ${WARMUPSTEPS}"
echo "save steps = ${SAVESTEPS}"
alias python=python3
start_time=`date +%s`
CUDA_VISIBLE_DEVICES=${GPUDEVICE} python run_classifier.py \
--spiece_model_file=${MODELDIR}/spiece.model \
--model_config_path=${MODELDIR}/xlnet_config.json \
--init_checkpoint=${MODELDIR}/xlnet_model.ckpt \
--task_name=${TASKNAME} \
--random_seed=${RANDOMSEED} \
--predict_tag=${PREDICTTAG} \
--lower_case=false \
--data_dir=${DATADIR}/ \
--output_dir=${OUTPUTDIR}/data \
--model_dir=${OUTPUTDIR}/checkpoint \
--export_dir=${OUTPUTDIR}/export \
--max_seq_length=${MAXLEN} \
--train_batch_size=${BATCHSIZE} \
--eval_batch_size=${BATCHSIZE} \
--predict_batch_size=${BATCHSIZE} \
--num_hosts=1 \
--num_core_per_host=${NUMGPUS} \
--learning_rate=${LEARNINGRATE} \
--train_steps=${TRAINSTEPS} \
--warmup_steps=${WARMUPSTEPS} \
--save_steps=${SAVESTEPS} \
--do_train=true \
--do_eval=false \
--do_predict=false \
--do_export=false \
--overwrite_data=false
CUDA_VISIBLE_DEVICES=${GPUDEVICE} python run_classifier.py \
--spiece_model_file=${MODELDIR}/spiece.model \
--model_config_path=${MODELDIR}/xlnet_config.json \
--init_checkpoint=${MODELDIR}/xlnet_model.ckpt \
--task_name=${TASKNAME} \
--random_seed=${RANDOMSEED} \
--predict_tag=${PREDICTTAG} \
--lower_case=false \
--data_dir=${DATADIR}/ \
--output_dir=${OUTPUTDIR}/data \
--model_dir=${OUTPUTDIR}/checkpoint \
--export_dir=${OUTPUTDIR}/export \
--max_seq_length=${MAXLEN} \
--train_batch_size=${BATCHSIZE} \
--eval_batch_size=${BATCHSIZE} \
--predict_batch_size=${BATCHSIZE} \
--num_hosts=1 \
--num_core_per_host=1 \
--learning_rate=${LEARNINGRATE} \
--train_steps=${TRAINSTEPS} \
--warmup_steps=${WARMUPSTEPS} \
--save_steps=${SAVESTEPS} \
--do_train=false \
--do_eval=true \
--do_predict=true \
--do_export=false \
--overwrite_data=false
python tool/eval_sent.py \
--input_file=${OUTPUTDIR}/data/predict.${PREDICTTAG}.json \
--output_file=${OUTPUTDIR}/data/predict.${PREDICTTAG}.sent
read -n 1 -s -r -p "Press any key to continue..."