Skip to content

Commit 7a53214

Browse files
authored
add ernie text cls test script (#733)
1 parent 3fdb1fd commit 7a53214

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/run_ernie_cls.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
batch_size=32
2+
epoch=1
3+
device=gpu
4+
gpu_list="2,3"
5+
save_dir=./ernie_text_cls_ckpt
6+
static_model_dir=./ernie_text_cls_export
7+
params_path=./ernie_text_cls_ckpt/model_100/model_state.pdparams
8+
static_output_path=${static_model_dir}/static_graph_params
9+
static_model_file=${static_model_dir}/static_graph_params.pdmodel
10+
static_params_file=${static_model_dir}/static_graph_params.pdiparams
11+
train_script=../examples/text_classification/pretrained_models/train.py
12+
export_script=../examples/text_classification/pretrained_models/export_model.py
13+
predict_script=../examples/text_classification/pretrained_models/deploy/python/predict.py
14+
distributed_log_dir=./ernie_text_cls_log
15+
echo "check and create directory"
16+
if [ ! -d ${static_model_dir} ]; then
17+
mkdir ${static_model_dir}
18+
echo "create dir ${static_model_dir}."
19+
else
20+
echo "dir ${static_model_dir} has already existed."
21+
fi
22+
23+
process_name=${1}
24+
25+
if [ ${process_name} == ernie_text_cls_train ]; then
26+
echo -e "\nstart ernie text classfication training."
27+
unset CUDA_VISIBLE_DEVICES
28+
python -m paddle.distributed.launch --gpus ${gpu_list} \
29+
--log_dir ${distributed_log_dir} \
30+
${train_script} \
31+
--device ${device} \
32+
--save_dir ${save_dir} \
33+
--batch_size ${batch_size} \
34+
--epoch ${epoch}
35+
echo -e "\nend ernie text classfication training."
36+
elif [ ${process_name} == ernie_text_cls_export ]; then
37+
echo -e "\nstart to export model for ernie text classfication."
38+
python ${export_script} --params_path=${params_path} --output_path=${static_output_path}
39+
echo -e "\nend to export model for ernie text classfication."
40+
elif [ ${process_name} == ernie_text_cls_predict ]; then
41+
echo -e "\nstart to ernie text classfication prediction."
42+
python ${predict_script} --device ${device} \
43+
--model_file=${static_model_file} \
44+
--params_file=${static_params_file}
45+
echo -e "\nend to ernie text classfication prediction."
46+
else
47+
echo "no process name ${process_name} ."
48+
fi

0 commit comments

Comments
 (0)