-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtrain.sh
executable file
·74 lines (63 loc) · 1.48 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
#!/usr/bin/env bash
# Copyright 2019 Jian Wu
# License: Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# wrapper for train_{ss,am,lm}.py
set -eu
gpu=0
seed=777
init=""
resume=""
epochs=100
trainer="ddp"
tensorboard=false
batch_size=64
num_workers=4
eval_interval=-1
save_interval=-1
prog_interval=100
dev_batch_factor=1
echo "$0 $*"
. ./utils/parse_options.sh || exit 1
[ $# -ne 3 ] && echo "Script format error: $0 <task> <data-set> <exp-id>" && exit 1
task=$1
data=$2
exp_id=$3
opts=""
case $task in
"am" | "lm" )
dict=data/$data/dict
[ ! -f $dict ] && echo "$0: missing dictionary $dict" && exit 1
opts="--dict $dict"
;;
"ss" )
;;
* )
echo "$0: Unknown task: $task" && exit 1
;;
esac
if [ "$task" = "lm" ]; then
conf=conf/$data/nnlm/$exp_id.yaml
checkpoint=exp/$data/nnlm/$exp_id
else
conf=conf/$data/$exp_id.yaml
checkpoint=exp/$data/$exp_id
fi
[ ! -f $conf ] && echo "$0: missing training configurations $conf" && exit 1
cmd/train_$task.py $opts \
--conf $conf \
--seed $seed \
--init "$init" \
--resume "$resume" \
--epochs $epochs \
--trainer $trainer \
--device-ids $gpu \
--batch-size $batch_size \
--checkpoint $checkpoint \
--num-workers $num_workers \
--tensorboard $tensorboard \
--save-interval $save_interval \
--prog-interval $prog_interval \
--eval-interval $eval_interval \
--dev-batch-factor $dev_batch_factor \
> $data.train_$task.$exp_id.log 2>&1
cp $data.train_$task.$exp_id.log exp/$data/$exp_id