run.sh 1.2 KB
Newer Older
J
Junkun 已提交
1 2 3 4
#!/bin/bash
set -e
source path.sh

H
Hui Zhang 已提交
5
gpus=0,1,2,3
J
Junkun 已提交
6 7 8 9
stage=0
stop_stage=100
conf_path=conf/transformer_joint_noam.yaml
avg_num=5
H
Hui Zhang 已提交
10
data_path=./TED_EnZh # path to unzipped data
J
Junkun 已提交
11 12 13 14 15 16 17 18 19
source ${MAIN_ROOT}/utils/parse_options.sh || exit 1;

avg_ckpt=avg_${avg_num}
ckpt=$(basename ${conf_path} | awk -F'.' '{print $1}')
echo "checkpoint name ${ckpt}"


if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
    # prepare data
H
Hui Zhang 已提交
20
    bash ./local/data.sh --data_dir ${data_path} || exit -1
J
Junkun 已提交
21 22 23 24
fi

if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
    # train model, all `ckpt` under `exp` dir
H
Hui Zhang 已提交
25
    CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt}
J
Junkun 已提交
26 27 28 29
fi

if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
    # avg n best model
H
Hui Zhang 已提交
30
    avg.sh best exp/${ckpt}/checkpoints ${avg_num}
J
Junkun 已提交
31 32 33 34 35 36 37
fi

if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
    # test ckpt avg_n
    CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
fi

H
Hui Zhang 已提交
38 39 40 41
# if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
#     # export ckpt avg_n
#     CUDA_VISIBLE_DEVICES= ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit
# fi